Skip to content
Snippets Groups Projects
Commit 32b6a5cf authored by Toledo97's avatar Toledo97
Browse files

saving address cycling

parent d082c629
No related branches found
No related tags found
No related merge requests found
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
lib_extra_dirs = ~/Documents/Arduino/libraries
lib_deps = deanisme/SevSeg@^3.7.1
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Example OpenOCD configuration file for ESP32-S3 connected via builtin USB-JTAG adapter.
#
# For example, OpenOCD can be started for ESP32-S3 debugging on
#
# openocd -f board/esp32s3-builtin.cfg
#
# Source the JTAG interface configuration file
source [find interface/esp_usb_jtag.cfg]
# Source the ESP32-S3 configuration file
source [find target/esp32s3.cfg]
This diff is collapsed.
{
"name":"Arduino on ESP32-S3",
"toolchainPrefix":"xtensa-esp32s3-elf",
"svdFile":"debug.svd",
"request":"attach",
"overrideAttachCommands":[
"set remote hardware-watchpoint-limit 2",
"monitor reset halt",
"monitor gdb_sync",
"thb setup",
"c"
],
"overrideRestartCommands":[
"monitor reset halt",
"monitor gdb_sync"
]
}
\ No newline at end of file
#define addrLimit 15
#define pinMax 4
const int addrPins[] = {46,3,8,18};
const int segmentPins[] = {17,16,15,7,6,5,4};
int address;
int plants;
const byte hexMap[16][7]={
// a,b,c,d,e,f,g
{1,1,1,1,1,1,0}, // 0
{0,1,1,0,0,0,0}, // 1
{1,1,0,1,1,0,1}, // 2
{1,1,1,1,0,0,1}, // 3
{0,1,1,0,0,1,1}, // 4
{1,0,1,1,0,1,1}, // 5
{1,0,1,1,1,1,1}, // 6
{1,1,1,0,0,0,0}, // 7
{1,1,1,1,1,1,1}, // 8
{1,1,1,1,0,1,1}, // 9
{1,1,1,0,1,1,1}, // A
{0,0,1,1,1,1,1}, // b
{1,0,0,1,1,1,0}, // C
{0,1,1,1,1,0,1}, // d
{1,0,0,1,1,1,1}, // E
{1,0,0,0,1,1,1}}; // F
void resetHex(){
for(byte i = 0 ; i < 7 ; i++){digitalWrite(segmentPins[i], LOW);}
}
void setHex(){
resetHex();
for(byte i = 0 ; i < 7 ; i++){
(hexMap[address][i]==1) ? digitalWrite(segmentPins[i], HIGH) : digitalWrite(segmentPins[i], LOW);
}
}
// output current address
void setAddr(){
if(address > addrLimit){
address = 0;
}
for (byte i=0; i<pinMax; i++) {
int state = bitRead(address, i);
digitalWrite(addrPins[i], state);
}
}
void cycle(){////
address = (address >= plants) ? 0 : address;
setAddr();
setHex();
address++;
}
static void cycle();
static void setHex(); // set hex led values
static void resetHex();
static void setPins();
static void setAddr();
#define write
\ No newline at end of file
#include <Arduino.h>
#include <h/prototypes.h>
#include <h/address_cycling.h>
#include <driver/gpio.h>
#define interval 1500 // (milliseconds)
#define write_pin 9
#define open_pin 10
int open_state;
unsigned long previousMillis = 0; // will store last time LED was updated
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(115200);
while(!Serial);
setPins();
plants = 16;
address = 0;
open_state = LOW;
}
// the loop function runs over and over again forever
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
// digitalWrite(open_pin, open_state);
// open_state = ~open_state;
cycle();
}
if(address == 3){
digitalWrite(open_pin, open_state);
open_state = ~open_state;
}
if (currentMillis - previousMillis >= interval/2.0) {
digitalWrite(write_pin, LOW);
}
else {
digitalWrite(write_pin, HIGH);
}
}
void setPins(){
pinMode(write_pin,OUTPUT);
pinMode(open_pin,OUTPUT);
digitalWrite(write_pin, LOW);
digitalWrite(open_pin, LOW);
for(int i = 0 ; i < 7 ; i ++){
if(i < pinMax){
pinMode(addrPins[i], OUTPUT);
digitalWrite(addrPins[i], LOW);
}
pinMode(segmentPins[i],OUTPUT);
}
}
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment