44const __attribute__ ((section(" .rodata_custom_desc" ))) CubePartition cubePartition = {CUBE_MAGIC_COOKIE};
55
66// Create a new Cube object with optional devMode
7- Cube::Cube () : serial(String(ESP.getEfuseMac() % 0x1000000, HEX)),
8- currentPattern(patterns::snake),
9- wifiReady(false ),
10- server(80 ),
11- dashboard(&server),
12- otaToggle(&dashboard, BUTTON_CARD, " OTA Update Enabled" ),
13- GHUpdateToggle(&dashboard, BUTTON_CARD, " Github Update Enabled" ),
14- developmentToggle(&dashboard, BUTTON_CARD, " Use Development Builds" ),
15- signedFWOnlyToggle(&dashboard, BUTTON_CARD, " Signed FW only" ),
16- fwVersion(&dashboard, " Firmware Version" , FW_VERSION),
17- brightnessSlider(&dashboard, SLIDER_CARD, " Brightness:" , " " , 0 , 255 )
18-
7+ Cube::Cube () : serial(String(ESP.getEfuseMac() % 0x1000000, HEX)),
8+ currentPattern(patterns::snake),
9+ wifiReady(false ),
10+ server(80 ),
11+ dashboard(&server),
12+ otaToggle(&dashboard, BUTTON_CARD, " OTA Update Enabled" ),
13+ GHUpdateToggle(&dashboard, BUTTON_CARD, " Github Update Enabled" ),
14+ developmentToggle(&dashboard, BUTTON_CARD, " Use Development Builds" ),
15+ signedFWOnlyToggle(&dashboard, BUTTON_CARD, " Signed FW only" ),
16+ fwVersion(&dashboard, " Firmware Version" , FW_VERSION),
17+ brightnessSlider(&dashboard, SLIDER_CARD, " Brightness:" , " " , 0 , 255 ),
18+ latchSlider(&dashboard, SLIDER_CARD, " Latch Blanking:" , " " , 1 , 4 ),
19+ use20MHzToggle(&dashboard, BUTTON_CARD, " Use 20MHz Clock" ),
20+ rebootButton(&dashboard, BUTTON_CARD, " Reboot Cube" ),
21+ resetWifiButton(&dashboard, BUTTON_CARD, " Reset Wifi" )
1922{
2023}
2124
@@ -67,11 +70,15 @@ void Cube::initDisplay()
6770 this ->printf (" Configuring HUB_75\n " );
6871 HUB75_I2S_CFG::i2s_pins _pins = {R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN};
6972 HUB75_I2S_CFG mxconfig (PANEL_WIDTH, PANEL_HEIGHT, PANELS_NUMBER, _pins);
70- mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M;
73+ if (cubePrefs.use20MHz ) {
74+ mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_20M;
75+ } else {
76+ mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M;
77+ }
7178 mxconfig.clkphase = false ;
7279 dma_display = new MatrixPanel_I2S_DMA (mxconfig);
7380 setBrightness (this ->cubePrefs .brightness );
74- dma_display->setLatBlanking (2 );
81+ dma_display->setLatBlanking (cubePrefs. latchBlanking );
7582
7683 // Allocate memory and start DMA display
7784 if (not dma_display->begin ())
@@ -84,7 +91,6 @@ void Cube::initWifi()
8491 pinMode (WIFI_LED, OUTPUT);
8592 digitalWrite (WIFI_LED, 0 );
8693 this ->printf (" Connecting to WiFi...\n " );
87- WiFiManager wifiManager;
8894 wifiManager.setHostname (" cube" );
8995 wifiManager.setClass (" invert" );
9096 wifiManager.autoConnect (" Cube" );
@@ -131,11 +137,40 @@ void Cube::initUI()
131137 this ->setBrightness (value);
132138 this ->brightnessSlider .update (value);
133139 this ->dashboard .sendUpdates (); });
140+ latchSlider.attachCallback ([&](int value)
141+ {
142+ this ->dma_display ->setLatBlanking (value);
143+ this ->cubePrefs .latchBlanking = value;
144+ this ->updatePrefs ();
145+ this ->latchSlider .update (value);
146+ this ->dashboard .sendUpdates (); });
147+ use20MHzToggle.attachCallback ([&](bool value)
148+ {
149+ this ->cubePrefs .use20MHz = value;
150+ this ->updatePrefs ();
151+ this ->use20MHzToggle .update (value);
152+ this ->dashboard .sendUpdates (); });
153+ rebootButton.attachCallback ([&](bool value)
154+ {
155+ this ->printf (" Rebooting..." );
156+ ESP.restart ();
157+ this ->dashboard .sendUpdates (); });
158+ resetWifiButton.attachCallback ([&](bool value)
159+ {
160+ this ->printf (" Resetting WiFi..." );
161+ wifiManager.resetSettings ();
162+ ESP.restart ();
163+ this ->dashboard .sendUpdates (); });
134164 this ->otaToggle .update (this ->cubePrefs .ota );
135165 this ->developmentToggle .update (this ->cubePrefs .development );
136166 this ->GHUpdateToggle .update (this ->cubePrefs .github );
137167 this ->brightnessSlider .update (this ->cubePrefs .brightness );
138168 this ->signedFWOnlyToggle .update (this ->cubePrefs .signedFWOnly );
169+ this ->latchSlider .update (this ->cubePrefs .latchBlanking );
170+ this ->use20MHzToggle .update (this ->cubePrefs .use20MHz );
171+ this ->rebootButton .update (true );
172+ this ->resetWifiButton .update (true );
173+
139174 dashboard.sendUpdates ();
140175}
141176
0 commit comments