-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
164 lines (133 loc) · 3.19 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Sat 19 Nov 00:27:15 UTC 2022
// +cpl +println
#define NOWDATE "Sat 19 Nov 00:27:15 UTC 2022"
#include <Arduino.h>
// stoalynne coad:
// https://learn.adafruit.com/adafruit-esp32-feather-v2/factory-reset
// thanks for the follow
#include <Adafruit_TestBed.h>
extern Adafruit_TestBed TB;
#define cr _cr(); // carriage return
#define lf _lf(); // carriage return
#define crlf _cr();_lf();
void _cr() { Serial.write(0x0d); }
void _lf() { Serial.write(0x0a); }
void cpl() {
int pin = LED_BUILTIN ;
bool state = digitalRead(pin);
state = !state;
digitalWrite(pin, state);
}
void blink() {
cpl();
delay(4);
cpl();
delay(7000);
}
#define NEOPIXEL_PIN 0
void setup_af_testbed() {
TB.neopixelPin = NEOPIXEL_PIN;
TB.neopixelNum = 1; // multi-rgb strip dotcom > '1' here
TB.begin(); // seems fine right here
TB.setColor(0x140000); // red
delay(1250);
TB.setColor(0x001400); // green
delay(1250);
TB.setColor(0x000014); // and blue - full monty
}
#define USE_RGB
#undef USE_RGB
void setup_rgb() {
pinMode(NEOPIXEL_I2C_POWER, OUTPUT);
#ifdef USE_RGB
digitalWrite(NEOPIXEL_I2C_POWER, HIGH);
#endif
#ifndef USE_RGB
digitalWrite(NEOPIXEL_I2C_POWER, LOW); // disable
#endif
setup_af_testbed();
}
void setup_gpio() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, 0);
delay(220);
#ifdef USE_RGB
setup_rgb();
#endif
}
void clrSerial() {
int avbl = Serial.available();
while (avbl > 0) {
char ch = Serial.read(); // flush
}
}
void signon_msg() {
// https://docs.platformio.org/en/stable/projectconf/section_env_build.html
// Serial.println("MYSTRING=<%s>\n", MYSTRING);
Serial.println(MYOTHERSTR);
Serial.println("\n");
// Serial.println(MYSTRING);
}
void setup_serial() {
if (!Serial) {
Serial.begin(115200);
// Serial.begin(76600);
// Serial.begin(74880);
clrSerial();
}
#if 0
while (!Serial) {
; // no new benefit
}
bool ser_state = Serial ; // true == connected?
if (ser_state) { // connected?
Serial.print(" Serial, rather than !Serial "); // this one prints
}
if (!ser_state) {
Serial.print(" !Serial, rather than Serial "); // this one does not print
}
#endif
delay(700);
crlf crlf crlf crlf
Serial.println("begin program.");
}
void setup(void) {
setup_serial();
delay(700);
setup_gpio(); delay(700);
crlf signon_msg(); delay(700);
}
uint8_t wheelColor=0;
int divider = 0;
void gonePrinting() {
Serial.print(" I am looping: fghij ");
// Serial.print(MYOTHERSTR);
Serial.println(MYSTRING);
cpl();
uint16_t szOfWhColMultpld = sizeof(wheelColor) * 256;
wheelColor = ( wheelColor + 1)& (
( szOfWhColMultpld - 1)
); // expect this to be 255 (256 - 1 = 255)
Serial.print(" icw: ");
Serial.println(wheelColor);
#ifdef USE_RGB
TB.setColor(TB.Wheel(wheelColor));
#endif
}
bool goprint;
void loop(void) {
blink();
#if 0
divider++;
if (divider > 27) {
divider = 0;
goprint = true;
}
if (goprint == true) {
gonePrinting();
goprint = false;
}
// delay(100);
#endif
}
// END.