Fixing Neoplixel Version
The Neopixel version was not working. I updated to the latest FastLED library that uses the RMT feature and a second core. I also updated the code to make it easier to deal with the differences between the Neopixel and Dotstar versions.
This commit is contained in:
@@ -35,7 +35,6 @@ This was ported from the [TWANG fork](https://github.com/bdring/TWANG) by bdring
|
|||||||
|
|
||||||
## TO DO List:
|
## TO DO List:
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
- Wireless features~~
|
- Wireless features~~
|
||||||
- 2 Player features by linking controllers. TBD
|
- 2 Player features by linking controllers. TBD
|
||||||
=======
|
=======
|
||||||
@@ -52,7 +51,6 @@ This was ported from the [TWANG fork](https://github.com/bdring/TWANG) by bdring
|
|||||||
- More robust.
|
- More robust.
|
||||||
- Integrated audio amplifier.
|
- Integrated audio amplifier.
|
||||||
- Python (it might be fun to make a Python version)
|
- Python (it might be fun to make a Python version)
|
||||||
>>>>>>> origin/master
|
|
||||||
|
|
||||||
- Digitized Audio
|
- Digitized Audio
|
||||||
- Currently the port uses the same square wave tones of the the Arduino version.
|
- Currently the port uses the same square wave tones of the the Arduino version.
|
||||||
|
|||||||
@@ -9,17 +9,27 @@
|
|||||||
It was inspired by Robin Baumgarten's Line Wobbler Game
|
It was inspired by Robin Baumgarten's Line Wobbler Game
|
||||||
|
|
||||||
Recent Changes
|
Recent Changes
|
||||||
- JOYSTICK_DEBUG was left on...turned it off
|
- Updated to move FastLEDshow to core 0
|
||||||
- Web page fields now have type='number' so they bring up a number keyboard
|
Fixed Neopixel
|
||||||
- Refresh the brightness when it changes.
|
- Used latest FastLED library..added compile check
|
||||||
- More Screen Savers
|
- Updated to move FastLEDshow to core 0
|
||||||
- Better looking reset after gameover
|
- Reduced MAX_LEDS on Neopixel
|
||||||
- Better looking restart after boss kill
|
- Move some defines to a separate config.h file to make them accessible to other files
|
||||||
- Updated readme with video and latest info
|
- Changed volume typo on serial port settings menu
|
||||||
|
|
||||||
|
Project TODO
|
||||||
|
- Make the strip type configurable via serial and wifi
|
||||||
|
|
||||||
|
|
||||||
|
Usage Notes:
|
||||||
|
- Changes to LED strip and other hardware are in config.h
|
||||||
|
- Change the strip type to what you are using and compile/load firmware
|
||||||
|
- Use Serial port or Wifi to set your strip length.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VERSION "2018-03-31"
|
//
|
||||||
|
|
||||||
|
#define VERSION "2018-06-28"
|
||||||
|
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
#include<Wire.h>
|
#include<Wire.h>
|
||||||
@@ -27,6 +37,7 @@
|
|||||||
#include "RunningMedian.h"
|
#include "RunningMedian.h"
|
||||||
|
|
||||||
// twang files
|
// twang files
|
||||||
|
#include "config.h"
|
||||||
#include "twang_mpu.h"
|
#include "twang_mpu.h"
|
||||||
#include "Enemy.h"
|
#include "Enemy.h"
|
||||||
#include "Particle.h"
|
#include "Particle.h"
|
||||||
@@ -39,33 +50,13 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "wifi_ap.h"
|
#include "wifi_ap.h"
|
||||||
|
|
||||||
|
#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
|
||||||
#define DATA_PIN 16
|
#error "Requires FastLED 3.1 or later; check github for latest code."
|
||||||
#define CLOCK_PIN 17
|
|
||||||
|
|
||||||
#define VIRTUAL_LED_COUNT 1000
|
|
||||||
|
|
||||||
// what type of LED Strip....uncomment only one
|
|
||||||
#define USE_APA102
|
|
||||||
//#define USE_NEOPIXEL
|
|
||||||
|
|
||||||
#ifdef USE_APA102
|
|
||||||
#define LED_TYPE APA102
|
|
||||||
#define LED_COLOR_ORDER BGR // typically this will be the order, but switch it if not
|
|
||||||
#define CONVEYOR_BRIGHTNES 8
|
|
||||||
#define LAVA_OFF_BRIGHTNESS 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_NEOPIXEL
|
|
||||||
#define CONVEYOR_BRIGHTNES 40 // low neopixel values are nearly off, they need a higher value
|
|
||||||
#define LAVA_OFF_BRIGHTNESS 15
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#define BRIGHTNESS 150
|
|
||||||
#define DIRECTION 1
|
#define DIRECTION 1
|
||||||
#define MIN_REDRAW_INTERVAL 16 // Min redraw interval (ms) 33 = 30fps / 16 = 63fps
|
|
||||||
#define USE_GRAVITY 0 // 0/1 use gravity (LED strip going up wall)
|
#define USE_GRAVITY 0 // 0/1 use gravity (LED strip going up wall)
|
||||||
#define BEND_POINT 550 // 0/1000 point at which the LED strip goes up the wall
|
#define BEND_POINT 550 // 0/1000 point at which the LED strip goes up the wall
|
||||||
|
|
||||||
@@ -75,8 +66,6 @@ int levelNumber = 0;
|
|||||||
|
|
||||||
#define TIMEOUT 20000 // time until screen saver in milliseconds
|
#define TIMEOUT 20000 // time until screen saver in milliseconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int joystickTilt = 0; // Stores the angle of the joystick
|
int joystickTilt = 0; // Stores the angle of the joystick
|
||||||
int joystickWobble = 0; // Stores the max amount of acceleration (wobble)
|
int joystickWobble = 0; // Stores the max amount of acceleration (wobble)
|
||||||
|
|
||||||
@@ -161,20 +150,77 @@ bool lastLevel = false;
|
|||||||
|
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
|
#define FASTLED_SHOW_CORE 0 // -- The core to run FastLED.show()
|
||||||
|
|
||||||
|
// -- Task handles for use in the notifications
|
||||||
|
static TaskHandle_t FastLEDshowTaskHandle = 0;
|
||||||
|
static TaskHandle_t userTaskHandle = 0;
|
||||||
|
|
||||||
|
/** show() for ESP32
|
||||||
|
* Call this function instead of FastLED.show(). It signals core 0 to issue a show,
|
||||||
|
* then waits for a notification that it is done.
|
||||||
|
*/
|
||||||
|
void FastLEDshowESP32()
|
||||||
|
{
|
||||||
|
if (userTaskHandle == 0) {
|
||||||
|
// -- Store the handle of the current task, so that the show task can
|
||||||
|
// notify it when it's done
|
||||||
|
userTaskHandle = xTaskGetCurrentTaskHandle();
|
||||||
|
|
||||||
|
// -- Trigger the show task
|
||||||
|
xTaskNotifyGive(FastLEDshowTaskHandle);
|
||||||
|
|
||||||
|
// -- Wait to be notified that it's done
|
||||||
|
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 200 );
|
||||||
|
ulTaskNotifyTake(pdTRUE, xMaxBlockTime);
|
||||||
|
userTaskHandle = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** show Task
|
||||||
|
* This function runs on core 0 and just waits for requests to call FastLED.show()
|
||||||
|
*/
|
||||||
|
void FastLEDshowTask(void *pvParameters)
|
||||||
|
{
|
||||||
|
// -- Run forever...
|
||||||
|
for(;;) {
|
||||||
|
// -- Wait for the trigger
|
||||||
|
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
||||||
|
|
||||||
|
// -- Do the show (synchronously)
|
||||||
|
FastLED.show();
|
||||||
|
|
||||||
|
// -- Notify the calling task
|
||||||
|
xTaskNotifyGive(userTaskHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.print("\r\nTWANG32 VERSION: "); Serial.println(VERSION);
|
Serial.print("\r\nTWANG32 VERSION: "); Serial.println(VERSION);
|
||||||
|
|
||||||
settings_init();
|
settings_init(); // load the user settings from EEPROM
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
accelgyro.initialize();
|
accelgyro.initialize();
|
||||||
|
|
||||||
FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, LED_COLOR_ORDER>(leds, VIRTUAL_LED_COUNT);
|
#ifdef USE_NEOPIXEL
|
||||||
|
Serial.print("\r\nCompiled for WS2812B (Neopixel) LEDs");
|
||||||
|
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, MAX_LEDS);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_APA102
|
||||||
|
Serial.print("\r\nCompiled for APA102 (Dotstar) LEDs");
|
||||||
|
FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, LED_COLOR_ORDER>(leds, MAX_LEDS);
|
||||||
|
#endif
|
||||||
|
|
||||||
FastLED.setBrightness(user_settings.led_brightness);
|
FastLED.setBrightness(user_settings.led_brightness);
|
||||||
FastLED.setDither(1);
|
FastLED.setDither(1);
|
||||||
|
|
||||||
|
// -- Create the ESP32 FastLED show task
|
||||||
|
xTaskCreatePinnedToCore(FastLEDshowTask, "FastLEDshowTask", 2048, NULL, 2, &FastLEDshowTaskHandle, FASTLED_SHOW_CORE);
|
||||||
|
|
||||||
sound_init(DAC_AUDIO_PIN);
|
sound_init(DAC_AUDIO_PIN);
|
||||||
|
|
||||||
ap_setup();
|
ap_setup();
|
||||||
@@ -182,13 +228,13 @@ void setup() {
|
|||||||
stage = STARTUP;
|
stage = STARTUP;
|
||||||
stageStartTime = millis();
|
stageStartTime = millis();
|
||||||
lives = user_settings.lives_per_level;
|
lives = user_settings.lives_per_level;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
long mm = millis();
|
long mm = millis();
|
||||||
int brightness = 0;
|
int brightness = 0;
|
||||||
|
|
||||||
|
|
||||||
ap_client_check(); // check for web client
|
ap_client_check(); // check for web client
|
||||||
checkSerialInput();
|
checkSerialInput();
|
||||||
|
|
||||||
@@ -207,6 +253,8 @@ void loop() {
|
|||||||
if (mm - previousMillis >= MIN_REDRAW_INTERVAL) {
|
if (mm - previousMillis >= MIN_REDRAW_INTERVAL) {
|
||||||
getInput();
|
getInput();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
long frameTimer = mm;
|
long frameTimer = mm;
|
||||||
previousMillis = mm;
|
previousMillis = mm;
|
||||||
|
|
||||||
@@ -219,10 +267,12 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(lastInputTime+TIMEOUT < mm){
|
if(lastInputTime+TIMEOUT < mm){
|
||||||
|
|
||||||
stage = SCREENSAVER;
|
stage = SCREENSAVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(stage == SCREENSAVER){
|
if(stage == SCREENSAVER){
|
||||||
screenSaverTick();
|
screenSaverTick();
|
||||||
}else if(stage == STARTUP){
|
}else if(stage == STARTUP){
|
||||||
@@ -249,7 +299,8 @@ void loop() {
|
|||||||
playerPosition += playerPositionModifier;
|
playerPosition += playerPositionModifier;
|
||||||
if(!attacking){
|
if(!attacking){
|
||||||
SFXtilt(joystickTilt);
|
SFXtilt(joystickTilt);
|
||||||
int moveAmount = (joystickTilt/6.0);
|
//int moveAmount = (joystickTilt/6.0); // 6.0 is ideal at 16ms interval (6.0 / (16.0 / MIN_REDRAW_INTERVAL))
|
||||||
|
int moveAmount = (joystickTilt/(6.0)); // 6.0 is ideal at 16ms interval
|
||||||
if(DIRECTION) moveAmount = -moveAmount;
|
if(DIRECTION) moveAmount = -moveAmount;
|
||||||
moveAmount = constrain(moveAmount, -MAX_PLAYER_SPEED, MAX_PLAYER_SPEED);
|
moveAmount = constrain(moveAmount, -MAX_PLAYER_SPEED, MAX_PLAYER_SPEED);
|
||||||
|
|
||||||
@@ -312,7 +363,8 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FastLED.show();
|
//FastLED.show();
|
||||||
|
FastLEDshowESP32();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,8 +710,6 @@ void tickStartup(long mm)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void tickEnemies(){
|
void tickEnemies(){
|
||||||
for(int i = 0; i<ENEMY_COUNT; i++){
|
for(int i = 0; i<ENEMY_COUNT; i++){
|
||||||
if(enemyPool[i].Alive()){
|
if(enemyPool[i].Alive()){
|
||||||
@@ -747,6 +797,7 @@ void tickSpawners(){
|
|||||||
void tickLava(){
|
void tickLava(){
|
||||||
int A, B, p, i, brightness, flicker;
|
int A, B, p, i, brightness, flicker;
|
||||||
long mm = millis();
|
long mm = millis();
|
||||||
|
|
||||||
Lava LP;
|
Lava LP;
|
||||||
for(i = 0; i<LAVA_COUNT; i++){
|
for(i = 0; i<LAVA_COUNT; i++){
|
||||||
LP = lavaPool[i];
|
LP = lavaPool[i];
|
||||||
@@ -759,8 +810,8 @@ void tickLava(){
|
|||||||
LP._lastOn = mm;
|
LP._lastOn = mm;
|
||||||
}
|
}
|
||||||
for(p = A; p<= B; p++){
|
for(p = A; p<= B; p++){
|
||||||
flicker = random8(3);
|
flicker = random8(LAVA_OFF_BRIGHTNESS);
|
||||||
leds[p] = CRGB(3+flicker, (3+flicker)/1.5, 0);
|
leds[p] = CRGB(LAVA_OFF_BRIGHTNESS+flicker, (LAVA_OFF_BRIGHTNESS+flicker)/1.5, 0);
|
||||||
}
|
}
|
||||||
}else if(LP._state == Lava::ON){
|
}else if(LP._state == Lava::ON){
|
||||||
if(LP._lastOn + LP._ontime < mm){
|
if(LP._lastOn + LP._ontime < mm){
|
||||||
@@ -769,12 +820,10 @@ void tickLava(){
|
|||||||
}
|
}
|
||||||
for(p = A; p<= B; p++){
|
for(p = A; p<= B; p++){
|
||||||
if(random8(30) < 29)
|
if(random8(30) < 29)
|
||||||
leds[p] = CRGB(150, 0, 0);
|
leds[p] = CRGB(150, 0, 0);
|
||||||
else
|
else
|
||||||
leds[p] = CRGB(180, 100, 0);
|
leds[p] = CRGB(180, 100, 0);
|
||||||
}
|
}
|
||||||
//if (random8(30) > 3)
|
|
||||||
//sound(380 + random8(200), MAX_VOLUME / 2); // scary lava noise
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lavaPool[i] = LP;
|
lavaPool[i] = LP;
|
||||||
@@ -824,7 +873,7 @@ void tickConveyors(){
|
|||||||
if(speed < 0)
|
if(speed < 0)
|
||||||
n = (led + (m/100)) % levels;
|
n = (led + (m/100)) % levels;
|
||||||
|
|
||||||
b = map(n, 5, 0, 0, CONVEYOR_BRIGHTNES);
|
b = map(n, 5, 0, 0, CONVEYOR_BRIGHTNESS);
|
||||||
if(b > 0)
|
if(b > 0)
|
||||||
leds[led] = CRGB(0, 0, b);
|
leds[led] = CRGB(0, 0, b);
|
||||||
}
|
}
|
||||||
|
|||||||
68
TWANG32/config.h
Normal file
68
TWANG32/config.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
TWANG32 - An ESP32 port of TWANG
|
||||||
|
(c) B. Dring 3/2018
|
||||||
|
License: Creative Commons 4.0 Attribution - Share Alike
|
||||||
|
|
||||||
|
TWANG was originally created by Critters
|
||||||
|
https://github.com/Critters/TWANG
|
||||||
|
|
||||||
|
Basic hardware definitions
|
||||||
|
|
||||||
|
Light Strip Notes:
|
||||||
|
|
||||||
|
Noepixel / WS2812
|
||||||
|
- Low Cost
|
||||||
|
- You might already have a strip.
|
||||||
|
- No Clock Line - This means a fixed and relatively slow data rate and only shorter strips can be used
|
||||||
|
- Poor Dynamic Range - The low end of brightness is basically not visible
|
||||||
|
Dotstar (Highly recommended)
|
||||||
|
- Higher Cost
|
||||||
|
- Higher speed - Longer strips can be used.
|
||||||
|
- Great dynamic range, so lower levels and more colors can be used.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_H
|
||||||
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#define DATA_PIN 16
|
||||||
|
#define CLOCK_PIN 17
|
||||||
|
|
||||||
|
/* Game is rendered to this and scaled down to your strip.
|
||||||
|
This allows level definitions to work on all strip lengths */
|
||||||
|
#define VIRTUAL_LED_COUNT 1000
|
||||||
|
|
||||||
|
// what type of LED Strip....uncomment to define only one of these
|
||||||
|
#define USE_APA102
|
||||||
|
//#define USE_NEOPIXEL
|
||||||
|
|
||||||
|
// Check to make sure LED choice was done right
|
||||||
|
#if !defined(USE_NEOPIXEL) && !defined(USE_APA102)
|
||||||
|
#error "You must have USE_APA102 or USE_NEOPIXEL defined in config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_NEOPIXEL) && defined(USE_APA102)
|
||||||
|
#error "Both USE_APA102 and USE_NEOPIXEL are defined in config.h. Only one can be used"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_APA102
|
||||||
|
#define LED_TYPE APA102
|
||||||
|
#define LED_COLOR_ORDER BGR // typically this will be the order, but switch it if not
|
||||||
|
#define CONVEYOR_BRIGHTNESS 8
|
||||||
|
#define LAVA_OFF_BRIGHTNESS 4
|
||||||
|
#define MAX_LEDS VIRTUAL_LED_COUNT // these LEDS can handle the max
|
||||||
|
#define MIN_REDRAW_INTERVAL 1000.0 / 60.0 // divide by frames per second..if you tweak adjust player speed
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_NEOPIXEL
|
||||||
|
#define LED_TYPE NEOPIXEL
|
||||||
|
#define CONVEYOR_BRIGHTNESS 40 // low neopixel values are nearly off, Neopixels need a higher value
|
||||||
|
#define LAVA_OFF_BRIGHTNESS 15 // low neopixel values are nearly off, Neopixels need a higher value
|
||||||
|
#define MAX_LEDS 288 // Neopixels cannot handle the framerate
|
||||||
|
#define MIN_REDRAW_INTERVAL 1000.0 / 60.0 // divide by frames per second..if you tweak adjust player speed
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
// LEDS
|
// LEDS
|
||||||
#define NUM_LEDS 144
|
#define NUM_LEDS 144
|
||||||
#define MIN_LEDS 60
|
#define MIN_LEDS 60
|
||||||
#define MAX_LEDS 1000
|
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_BRIGHTNESS 150
|
#define DEFAULT_BRIGHTNESS 150
|
||||||
@@ -40,13 +40,10 @@ const uint8_t LIVES_PER_LEVEL = 3; // default lives per level
|
|||||||
#define MAX_JOYSTICK_DEADZONE 12
|
#define MAX_JOYSTICK_DEADZONE 12
|
||||||
|
|
||||||
// AUDIO
|
// AUDIO
|
||||||
#define DEFAULT_VOLUME 180 // 0 to 255
|
#define DEFAULT_VOLUME 20 // 0 to 255
|
||||||
#define MIN_VOLUME 0
|
#define MIN_VOLUME 0
|
||||||
#define MAX_VOLUME 255
|
#define MAX_VOLUME 255
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DAC_AUDIO_PIN 25 // should be 25 or 26 only
|
#define DAC_AUDIO_PIN 25 // should be 25 or 26 only
|
||||||
|
|
||||||
enum ErrorNums{
|
enum ErrorNums{
|
||||||
@@ -122,6 +119,7 @@ void processSerial(char inChar)
|
|||||||
switch(readBuffer[readIndex]){
|
switch(readBuffer[readIndex]){
|
||||||
case '?':
|
case '?':
|
||||||
readIndex = 0;
|
readIndex = 0;
|
||||||
|
show_game_stats();
|
||||||
show_settings_menu();
|
show_settings_menu();
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
@@ -295,7 +293,10 @@ void show_settings_menu() {
|
|||||||
|
|
||||||
Serial.print("\r\nC=");
|
Serial.print("\r\nC=");
|
||||||
Serial.print(user_settings.led_count);
|
Serial.print(user_settings.led_count);
|
||||||
Serial.println(" (LED Count 100-1000..forces restart)");
|
|
||||||
|
Serial.print(" (LED Count 60-");
|
||||||
|
Serial.print(MAX_LEDS);
|
||||||
|
Serial.println(")");
|
||||||
|
|
||||||
Serial.print("B=");
|
Serial.print("B=");
|
||||||
Serial.print(user_settings.led_brightness);
|
Serial.print(user_settings.led_brightness);
|
||||||
@@ -303,7 +304,7 @@ void show_settings_menu() {
|
|||||||
|
|
||||||
Serial.print("S=");
|
Serial.print("S=");
|
||||||
Serial.print(user_settings.audio_volume);
|
Serial.print(user_settings.audio_volume);
|
||||||
Serial.println(" (Sound Volume 0-10)");
|
Serial.println(" (Sound Volume 0-255)");
|
||||||
|
|
||||||
Serial.print("D=");
|
Serial.print("D=");
|
||||||
Serial.print(user_settings.joystick_deadzone);
|
Serial.print(user_settings.joystick_deadzone);
|
||||||
@@ -325,7 +326,7 @@ void show_settings_menu() {
|
|||||||
|
|
||||||
void show_game_stats()
|
void show_game_stats()
|
||||||
{
|
{
|
||||||
Serial.println("\r\n ===== Play statistics ======");
|
Serial.println("\r\n===== Play statistics ======");
|
||||||
Serial.print("Games played: ");Serial.println(user_settings.games_played);
|
Serial.print("Games played: ");Serial.println(user_settings.games_played);
|
||||||
if (user_settings.games_played > 0) {
|
if (user_settings.games_played > 0) {
|
||||||
Serial.print("Average Score: ");Serial.println(user_settings.total_points / user_settings.games_played);
|
Serial.print("Average Score: ");Serial.println(user_settings.total_points / user_settings.games_played);
|
||||||
@@ -367,16 +368,10 @@ void settings_eeprom_read() {
|
|||||||
|
|
||||||
void settings_eeprom_write() {
|
void settings_eeprom_write() {
|
||||||
|
|
||||||
Serial.println("Settings write...");
|
|
||||||
|
|
||||||
sound_pause(); // prevent interrupt from causing crash
|
sound_pause(); // prevent interrupt from causing crash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EEPROM.begin(EEPROM_SIZE);
|
EEPROM.begin(EEPROM_SIZE);
|
||||||
|
|
||||||
Serial.println("EEPROM open for write...");
|
|
||||||
|
|
||||||
uint8_t temp[sizeof(user_settings)];
|
uint8_t temp[sizeof(user_settings)];
|
||||||
memcpy(temp, (uint8_t*)&user_settings, sizeof(user_settings));
|
memcpy(temp, (uint8_t*)&user_settings, sizeof(user_settings));
|
||||||
|
|
||||||
@@ -386,7 +381,6 @@ void settings_eeprom_write() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
|
|
||||||
EEPROM.end();
|
EEPROM.end();
|
||||||
|
|
||||||
sound_resume(); // restore sound interrupt
|
sound_resume(); // restore sound interrupt
|
||||||
|
|||||||
@@ -54,9 +54,15 @@ void sendStatsPage(WiFiClient client) {
|
|||||||
|
|
||||||
client.print("<table>");
|
client.print("<table>");
|
||||||
|
|
||||||
client.print("<tr><td>LED Count (60-1000)</td><td><form><input type='number' name='C' value='");
|
|
||||||
|
client.print("<tr><td>");
|
||||||
|
client.print("LED Count (60-");
|
||||||
|
client.print(MAX_LEDS);
|
||||||
|
client.print(")</td><td><form><input type='number' name='C' value='");
|
||||||
client.print(user_settings.led_count);
|
client.print(user_settings.led_count);
|
||||||
client.print ("' min='60' max='1000'><input type='submit'></form></td></tr>");
|
client.print ("' min='60' max='");
|
||||||
|
client.print (MAX_LEDS);
|
||||||
|
client.print ("'><input type='submit'></form></td></tr>");
|
||||||
|
|
||||||
client.print("<tr><td>Brightness (10-255)</td><td><form><input type='number' name='B' value='");
|
client.print("<tr><td>Brightness (10-255)</td><td><form><input type='number' name='B' value='");
|
||||||
client.print(user_settings.led_brightness);
|
client.print(user_settings.led_brightness);
|
||||||
|
|||||||
Reference in New Issue
Block a user