changes from camp

This commit is contained in:
interfisch 2024-08-29 18:03:46 +02:00
parent 5e77c79071
commit a7e2023470
7 changed files with 83 additions and 13 deletions

View File

@ -164,9 +164,9 @@ void setup() {
.setSize(100, 20); .setSize(100, 20);
myPort = new Serial(this, "/dev/ttyUSB0", 115200);
//myPort = new Serial(this, "COM3", 115200); //myPort = new Serial(this, "COM3", 115200);
myPort = new Serial(this, "/dev/ttyUSB0", 115200);
} }
void Set() { void Set() {

View File

@ -14,5 +14,5 @@ do
printf "%c" "." printf "%c" "."
done done
printf "\n%s\n" "Device is online" printf "\n%s\n" "Device is online"
pio run -t upload --upload-port $1 pio run -t upload --upload-port $1 -e d1_mini-ota

View File

@ -16,6 +16,22 @@ framework = arduino
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_deps =
adafruit/Adafruit NeoPixel @ ^1.7.0
[env:d1_mini-ota]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
upload_speed = 921600
upload_protocol = espota
lib_deps = lib_deps =
adafruit/Adafruit NeoPixel @ ^1.7.0 adafruit/Adafruit NeoPixel @ ^1.7.0

View File

@ -1,7 +1,7 @@
//flash as Wemos D1 R2 & mini //flash as Wemos D1 R2 & mini
#include <Arduino.h> #include <Arduino.h>
#include "simpleota.h" //#include "simpleota.h"
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
#ifdef __AVR__ #ifdef __AVR__
@ -97,6 +97,13 @@ long last_changePersistancemode=0;
#define MAXWAGONS 5 //maximum number of wagons #define MAXWAGONS 5 //maximum number of wagons
//Wifi
//int port = 8888; //Port number
//WiFiServer server(port);
//WiFiClient client;
//uint8_t state_server=0;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
@ -114,17 +121,24 @@ void setup() {
strip.show(); // Initialize all pixels to 'off' strip.show(); // Initialize all pixels to 'off'
checkOTA(); /*checkOTA();
if(initOTA()) { //initialize ota if ota enabled if(initOTA()) { //initialize ota if ota enabled
return; //if ota do nothing else for setup Serial.println("OTA Initialized");
return;
} }
//server.begin();
*/
Serial.println("Started"); Serial.println("Started");
resetHeightmap(); resetHeightmap();
//fixed heightmap
loadHeightmapRaw(); loadHeightmapRaw();
interpolateHeightValues(); interpolateHeightValues();
@ -135,8 +149,6 @@ void setup() {
Serial.print(": "); Serial.print(": ");
Serial.println(height[i]); Serial.println(height[i]);
}*/ }*/
@ -288,7 +300,7 @@ void spawnWagon(){
//Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,30,0,40)/10.0, map(_randomlength,3,30, 5,60))/10.0 , 0 , random(3.0,7.0) , Wheel((uint8_t)random(0,255))); //spawn new wagon //Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,30,0,40)/10.0, map(_randomlength,3,30, 5,60))/10.0 , 0 , random(3.0,7.0) , Wheel((uint8_t)random(0,255))); //spawn new wagon
//Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,30,30,100)/10.0, map(_randomlength,3,30, 5,60))/10.0 , 0 , 1.8 , Wheel((uint8_t)random(0,255))); //spawn new wagon //Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,30,30,100)/10.0, map(_randomlength,3,30, 5,60))/10.0 , 0 , 1.8 , Wheel((uint8_t)random(0,255))); //spawn new wagon
Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,30,3,10)/10.0, map(_randomlength,3,30, 1,10))/10.0 , 0 , 1.8 , Wheel((uint8_t)random(0,255))); //spawn new wagon . start from near standstill Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(0,random(10,60))/10.0 , 0 , random(2,5)/10.0 , Wheel((uint8_t)random(0,255))); //spawn new wagon . start from near standstill
//Mass: the lighter the faster is changes speed //Mass: the lighter the faster is changes speed
@ -315,9 +327,47 @@ void spawnWagon(float pos, float wagonlength,float startvel, float startacc, flo
void loop() { void loop() {
//ota deactivated because of problems with exceptions/reboots. also maybe problems with eeprom and ota.
/*
if (loopOTA()) { if (loopOTA()) {
#ifndef OTA_CONTINUOUS
return; //just wait for ota return; //just wait for ota
#endif
} }
*/
/*
if (state_server==0)
{
client = server.available();
if (client) {
if(client.connected())
{
Serial.println("Client Connected");
state_server=1;
}
}
}
if (state_server==1) {
if(client.connected()){
while(client.available()>0){
// read data from the connected client
Serial.write(client.read());
}
//Send Data to connected client
while(Serial.available()>0)
{
client.write(Serial.read());
}
}else{
client.stop();
Serial.println("Client disconnected");
state_server=0;
}
}
*/
loopmillis=millis(); loopmillis=millis();
@ -684,8 +734,9 @@ void loadHeightmapRaw(){
heightraw[i]=lastvalue; heightraw[i]=lastvalue;
c_eepromaddress++; c_eepromaddress++;
} }
interpolateHeightValues();
} }
void saveHeightmapRaw(){ void saveHeightmapRaw(){
int c_eepromaddress=EEPROMSTARTADDRESS_HEIGHTMAP; int c_eepromaddress=EEPROMSTARTADDRESS_HEIGHTMAP;
for (int i=0;i<NUMPIXELS;i++){ for (int i=0;i<NUMPIXELS;i++){

View File

@ -76,10 +76,12 @@ bool loopOTA() {
if (otaMode != NONE) { if (otaMode != NONE) {
ArduinoOTA.handle(); ArduinoOTA.handle();
if(otaMode == WAITING) { if(otaMode == WAITING) {
static long mil = millis(); static long mil = millis();
static boolean huehott = false; static boolean huehott = false;
if(millis() - mil > 100) { if(millis() - mil > 100) {
huehott = !huehott; huehott = !huehott;
mil = millis(); mil = millis();

View File

@ -13,6 +13,7 @@
#define OTA_WAIT_TIMEOUT 50 // in 0.1s increments -> 10s #define OTA_WAIT_TIMEOUT 50 // in 0.1s increments -> 10s
#define OTA_PASSWORD "ROLLERCOASTER" //password needed for ota flashing #define OTA_PASSWORD "ROLLERCOASTER" //password needed for ota flashing
//#define OTA_CONTINUOUS
void checkOTA(); void checkOTA();

View File

@ -2,8 +2,8 @@
#define WAGONLENGTH 3 #define WAGONLENGTH 3
#define EDGE_KILL //#define EDGE_KILL
//#define EDGE_WALL #define EDGE_WALL
//#define EDGE_BOUNCE //#define EDGE_BOUNCE
//#define EDGE_WRAP //#define EDGE_WRAP
#define WRAPLEDENDPOS _numpixels //default #define WRAPLEDENDPOS _numpixels //default