changes from camp
This commit is contained in:
parent
5e77c79071
commit
a7e2023470
|
@ -164,9 +164,9 @@ void setup() {
|
|||
.setSize(100, 20);
|
||||
|
||||
|
||||
|
||||
myPort = new Serial(this, "/dev/ttyUSB0", 115200);
|
||||
|
||||
//myPort = new Serial(this, "COM3", 115200);
|
||||
myPort = new Serial(this, "/dev/ttyUSB0", 115200);
|
||||
}
|
||||
|
||||
void Set() {
|
||||
|
|
|
@ -14,5 +14,5 @@ do
|
|||
printf "%c" "."
|
||||
done
|
||||
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
|
||||
|
||||
|
|
|
@ -16,6 +16,22 @@ framework = arduino
|
|||
monitor_speed = 115200
|
||||
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 =
|
||||
adafruit/Adafruit NeoPixel @ ^1.7.0
|
||||
|
||||
|
|
67
src/main.cpp
67
src/main.cpp
|
@ -1,7 +1,7 @@
|
|||
//flash as Wemos D1 R2 & mini
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "simpleota.h"
|
||||
//#include "simpleota.h"
|
||||
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#ifdef __AVR__
|
||||
|
@ -97,6 +97,13 @@ long last_changePersistancemode=0;
|
|||
#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() {
|
||||
Serial.begin(115200);
|
||||
|
||||
|
@ -114,17 +121,24 @@ void setup() {
|
|||
strip.show(); // Initialize all pixels to 'off'
|
||||
|
||||
|
||||
checkOTA();
|
||||
/*checkOTA();
|
||||
|
||||
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");
|
||||
|
||||
resetHeightmap();
|
||||
|
||||
//fixed heightmap
|
||||
|
||||
loadHeightmapRaw();
|
||||
|
||||
|
||||
|
||||
interpolateHeightValues();
|
||||
|
||||
|
@ -135,8 +149,6 @@ void setup() {
|
|||
Serial.print(": ");
|
||||
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,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
|
||||
|
||||
|
||||
|
@ -315,9 +327,47 @@ void spawnWagon(float pos, float wagonlength,float startvel, float startacc, flo
|
|||
|
||||
void loop() {
|
||||
|
||||
//ota deactivated because of problems with exceptions/reboots. also maybe problems with eeprom and ota.
|
||||
/*
|
||||
if (loopOTA()) {
|
||||
#ifndef OTA_CONTINUOUS
|
||||
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();
|
||||
|
||||
|
@ -684,8 +734,9 @@ void loadHeightmapRaw(){
|
|||
heightraw[i]=lastvalue;
|
||||
c_eepromaddress++;
|
||||
}
|
||||
interpolateHeightValues();
|
||||
}
|
||||
|
||||
|
||||
void saveHeightmapRaw(){
|
||||
int c_eepromaddress=EEPROMSTARTADDRESS_HEIGHTMAP;
|
||||
for (int i=0;i<NUMPIXELS;i++){
|
||||
|
|
|
@ -76,10 +76,12 @@ bool loopOTA() {
|
|||
if (otaMode != NONE) {
|
||||
ArduinoOTA.handle();
|
||||
|
||||
|
||||
if(otaMode == WAITING) {
|
||||
static long mil = millis();
|
||||
static boolean huehott = false;
|
||||
|
||||
|
||||
if(millis() - mil > 100) {
|
||||
huehott = !huehott;
|
||||
mil = millis();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define OTA_WAIT_TIMEOUT 50 // in 0.1s increments -> 10s
|
||||
#define OTA_PASSWORD "ROLLERCOASTER" //password needed for ota flashing
|
||||
|
||||
//#define OTA_CONTINUOUS
|
||||
|
||||
|
||||
void checkOTA();
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#define WAGONLENGTH 3
|
||||
|
||||
#define EDGE_KILL
|
||||
//#define EDGE_WALL
|
||||
//#define EDGE_KILL
|
||||
#define EDGE_WALL
|
||||
//#define EDGE_BOUNCE
|
||||
//#define EDGE_WRAP
|
||||
#define WRAPLEDENDPOS _numpixels //default
|
||||
|
|
Loading…
Reference in New Issue