2424
2525#include " Hardware.h"
2626
27+ #include " Aurora.h"
28+
2729uint8_t brightness = 255 ;
2830uint8_t backgroundBrightness = 63 ;
2931
@@ -37,9 +39,6 @@ uint8_t backgroundBrightnessMap[brightnessCount] = { 8, 16, 32, 64, 128 };
3739#include < SPI.h>
3840#include < SD.h>
3941
40- const int MATRIX_CENTER_X = MATRIX_WIDTH / 2 ;
41- const int MATRIX_CENTER_Y = MATRIX_HEIGHT / 2 ;
42-
4342#include < Wire.h>
4443#include < Time.h>
4544#include < DS1307RTC.h>
@@ -76,6 +75,9 @@ bool isTimeAvailable = false;
7675#include " ClockDigitalShort.h"
7776ClockDigitalShort clockDigitalShort;
7877
78+ #include " ClockText.h"
79+ ClockText clockText;
80+
7981#include " ClockDisplay.h"
8082ClockDisplay clockDisplay;
8183
@@ -87,6 +89,9 @@ Animations animations;
8789
8890#include " Bitmaps.h"
8991
92+ rgb24 menuColor = CRGB(CRGB::Blue);
93+ int autoPlayDurationSeconds = 10 ;
94+
9095#include " MenuItem.h"
9196#include " Menu.h"
9297Menu menu;
@@ -97,14 +102,19 @@ Settings settings;
97102#include " SettingsSetTime.h"
98103#include " SettingsMoveClock.h"
99104
105+ #include " StreamingMode.h"
106+ StreamingMode streamingMode;
107+
100108MenuItem menuItemPatterns = MenuItem(" Patterns" , &patterns);
101109MenuItem menuItemAnimations = MenuItem(" Animations" , &animations);
110+ MenuItem menuItemStreamingMode = MenuItem(" Streaming Mode" , &streamingMode);
102111MenuItem menuItemSettings = MenuItem(" Settings" , &settings);
103112
104113// Main Menu
105114MenuItem* mainMenuItems [] = {
106115 &menuItemPatterns,
107116 &menuItemAnimations,
117+ &menuItemStreamingMode,
108118 &menuItemSettings,
109119};
110120
@@ -117,8 +127,8 @@ void setup()
117127 // Setup serial interface
118128 Serial.begin (9600 );
119129
120- // delay(3000);
121- // Serial.println(F("starting..."));
130+ // delay(3000);
131+ // Serial.println(F("starting..."));
122132
123133 // Initialize the IR receiver
124134 irReceiver.enableIRIn ();
@@ -170,6 +180,11 @@ void setup()
170180 if (enableStartupSplash) {
171181 while (matrix.getScrollStatus () != 0 ) {}
172182 }
183+
184+ if (!HAS_IR) {
185+ menu.playbackState = Menu::PlaybackState::Autoplay;
186+ menu.visible = false ;
187+ }
173188}
174189
175190void loop ()
@@ -207,6 +222,12 @@ void loadSettings() {
207222 boundBackgroundBrightness ();
208223 matrix.setBackgroundBrightness (backgroundBrightness);
209224
225+ menuColor.red = loadIntSetting (" /aurora/" , " /aurora/menuR.txt" , 3 , 0 );
226+ menuColor.green = loadIntSetting (" /aurora/" , " /aurora/menuG.txt" , 3 , 0 );
227+ menuColor.blue = loadIntSetting (" /aurora/" , " /aurora/menuB.txt" , 3 , 255 );
228+
229+ autoPlayDurationSeconds = loadIntSetting (" /aurora/" , " /aurora/autoplyd.txt" , 3 , 10 );
230+
210231 clockDisplay.loadSettings ();
211232}
212233
@@ -244,11 +265,11 @@ void adjustBrightness(int delta) {
244265 brightness = brightnessMap[level];
245266 boundBrightness ();
246267 matrix.setBrightness (brightness);
247- saveBrightnessSetting ();
248268}
249269
250270uint8_t cycleBrightness () {
251271 adjustBrightness (1 );
272+ saveBrightnessSetting ();
252273
253274 if (brightness == brightnessMap[0 ])
254275 return 0 ;
@@ -274,7 +295,6 @@ void adjustBackgroundBrightness(int d) {
274295 backgroundBrightness = backgroundBrightnessMap[level];
275296 boundBackgroundBrightness ();
276297 matrix.setBackgroundBrightness (backgroundBrightness);
277- saveBackgroundBrightnessSetting ();
278298}
279299
280300void boundBrightness () {
@@ -299,6 +319,28 @@ void saveBackgroundBrightnessSetting() {
299319 saveIntSetting (" /aurora/" , " /aurora/bckbrght.txt" , backgroundBrightness);
300320}
301321
322+ void saveMenuColor () {
323+ saveMenuR ();
324+ saveMenuG ();
325+ saveMenuB ();
326+ }
327+
328+ void saveMenuR () {
329+ saveIntSetting (" /aurora/" , " /aurora/menuR.txt" , menuColor.red );
330+ }
331+
332+ void saveMenuG () {
333+ saveIntSetting (" /aurora/" , " /aurora/menuG.txt" , menuColor.green );
334+ }
335+
336+ void saveMenuB () {
337+ saveIntSetting (" /aurora/" , " /aurora/menuB.txt" , menuColor.blue );
338+ }
339+
340+ void saveAutoPlayDurationSeconds () {
341+ saveIntSetting (" /aurora/" , " /aurora/autoplyd.txt" , autoPlayDurationSeconds);
342+ }
343+
302344int loadIntSetting (char * dir, const char * settingPath, int maxLength, int defaultValue) {
303345 if (!sdAvailable)
304346 return defaultValue;
@@ -354,4 +396,14 @@ void saveIntSetting(char* dir, const char* settingPath, int value) {
354396 file.print (value, 10 );
355397 file.close ();
356398 }
357- }
399+ }
400+
401+ // translates from x, y into an index into the LED array
402+ uint16_t XY (uint8_t x, uint8_t y) {
403+ if (y >= MATRIX_HEIGHT) { y = MATRIX_HEIGHT - 1 ; }
404+ if (y < 0 ) { y = 0 ; }
405+ if (x >= MATRIX_WIDTH) { x = MATRIX_WIDTH - 1 ; }
406+ if (x < 0 ) { x = 0 ; }
407+
408+ return (y * MATRIX_WIDTH) + x;
409+ }
0 commit comments