Adding motionsensor and starting param thing
This commit is contained in:
parent
da491f3dca
commit
e3b7976781
202
biciClock.ino
202
biciClock.ino
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#define STATION_UID "93" // location id
|
||||
#define HOST "testing.lbsfilm.at"
|
||||
#define HOST "bici.lbsfilm.at"
|
||||
|
||||
#define REFRESH 1000
|
||||
|
||||
@ -45,17 +45,35 @@ String bicis = "";
|
||||
String hours = "";
|
||||
String minutes = "";
|
||||
|
||||
char stationId[6] = "93";
|
||||
bool displayOn = false;
|
||||
|
||||
//flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
void saveConfigCallback () {
|
||||
Serial.println("Should save config");
|
||||
shouldSaveConfig = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
//WiFiManagerParameter custom_station_id)("server", "station id", mqtt_server, 40);
|
||||
EEPROM.begin(512);
|
||||
//EEPROM.begin(512);
|
||||
//stationId = EEPROM.read(25);
|
||||
|
||||
|
||||
WiFiManagerParameter custom_station_id("server", "station id", stationId, 6);
|
||||
WiFiManager wifiManager;
|
||||
|
||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
||||
wifiManager.autoConnect("ConfigureClock");
|
||||
//wifiManager.addParameter(&custom_station_id);
|
||||
//Serial.println(custom_station_id).getValue());
|
||||
wifiManager.addParameter(&custom_station_id);
|
||||
Serial.println(custom_station_id.getValue());
|
||||
if (shouldSaveConfig) {
|
||||
Serial.println("saving config");
|
||||
//EEPROM.write(25);
|
||||
}
|
||||
|
||||
clock.begin();
|
||||
clock.show(); // Initialize all pixels to 'off'
|
||||
@ -63,61 +81,8 @@ void setup() {
|
||||
delay(1000);
|
||||
colorWipe( clock.Color(0, 100, 150), 10);
|
||||
colorWipe( clock.Color(0, 0, 0), 5);
|
||||
displayNumber("99:99", clock.Color(150, 150, 150));
|
||||
}
|
||||
|
||||
void displayNumber(String string, uint32_t color) {
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i < 2) fillNumber(i, string[i] - 48, color);
|
||||
else fillNumber(i, string[i + 1] - 48, color);
|
||||
}
|
||||
|
||||
if (string[2] == ':') colon(color);
|
||||
else nocolon();
|
||||
|
||||
}
|
||||
|
||||
void noclock() {
|
||||
for (int led = 0; led < clock.numPixels(); led++) {
|
||||
clock.setPixelColor(led, 0);
|
||||
}
|
||||
clock.show();
|
||||
}
|
||||
|
||||
|
||||
void colon(uint32_t color) {
|
||||
for (int led = 0; led < SEPLEN; led++) {
|
||||
int currentLed = SEGLEN * 14 + led;
|
||||
clock.setPixelColor(currentLed, color);
|
||||
}
|
||||
clock.show();
|
||||
}
|
||||
|
||||
void nocolon() {
|
||||
for (int led = 0; led < SEPLEN; led++) {
|
||||
int currentLed = SEGLEN * 14 + led;
|
||||
clock.setPixelColor(currentLed, 0);
|
||||
}
|
||||
clock.show();
|
||||
}
|
||||
|
||||
void fillNumber(int position, int digit, uint32_t color) {
|
||||
int offset = 0;
|
||||
if (position > 3)return;
|
||||
if (position < 0)return;
|
||||
if (position > 1) offset = SEPLEN;
|
||||
|
||||
for (int seg = 0; seg < 7; seg++) {
|
||||
for (int led = 0; led < SEGLEN; led++) {
|
||||
int currentLed = position * 5 * 7 + seg * 5 + led + offset;
|
||||
if (digits[digit][seg] == 1) {
|
||||
clock.setPixelColor(currentLed, color);
|
||||
} else {
|
||||
clock.setPixelColor(currentLed, clock.Color(0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
//displayNumber("99:99", clock.Color(150, 150, 150));
|
||||
//countUp( clock.Color(0, 100, 150), 100);
|
||||
}
|
||||
|
||||
|
||||
@ -125,52 +90,20 @@ void loop() // Main loop
|
||||
{
|
||||
// Check motion sensor
|
||||
// get data and time
|
||||
displayOn = digitalRead(D6);
|
||||
|
||||
if (millis() - oldTime > REFRESH) {
|
||||
uint32_t c = clock.Color(10, 10, 10);
|
||||
getData();
|
||||
displayNumber(hours + ":" + minutes, c);
|
||||
if(displayOn) displayNumber(hours + ":" + minutes, c);
|
||||
Serial.println(hours + ":" + minutes);
|
||||
}
|
||||
|
||||
/*
|
||||
fillNumber(3, 0, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(0, 1, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(1, 2, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(2, 3, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(3, 4, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(0, 5, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(1, 6, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(2, 7, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(3, 8, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
fillNumber(0, 9, c);
|
||||
clock.show();
|
||||
delay(1000);
|
||||
*/
|
||||
}
|
||||
|
||||
void getData() {
|
||||
HTTPClient https;
|
||||
|
||||
https.begin("https://testing.lbsfilm.at/stations?stationId=93", "1D:62:C5:06:5E:45:51:26:2F:56:A5:BD:E9:5E:F1:33:C8:6C:66:05"); //HTTPS
|
||||
String URL = "https://" + String(HOST) + "/stations?stationId=" + String(STATION_UID);
|
||||
https.begin( URL, "1D:62:C5:06:5E:45:51:26:2F:56:A5:BD:E9:5E:F1:33:C8:6C:66:05"); //HTTPS
|
||||
int httpCode = https.GET();
|
||||
|
||||
if (httpCode > 0) {
|
||||
@ -208,7 +141,7 @@ void getData() {
|
||||
int offsetting = hours.toInt();
|
||||
offsetting = offsetting + OFFSET;
|
||||
if (offsetting == 24) offsetting = 0;
|
||||
if(offsetting<10) hours = "0" + String(offsetting, DEC);
|
||||
if (offsetting < 10) hours = "0" + String(offsetting, DEC);
|
||||
else hours = String(offsetting, DEC);
|
||||
|
||||
}
|
||||
@ -309,3 +242,78 @@ uint32_t Wheel(byte WheelPos) {
|
||||
return clock.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
|
||||
}
|
||||
|
||||
// ############### The LED Strip handling ###################
|
||||
|
||||
void displayNumber(String string, uint32_t color) {
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i < 2) fillNumber(i, string[i] - 48, color);
|
||||
else fillNumber(i, string[i + 1] - 48, color);
|
||||
}
|
||||
|
||||
if (string[2] == ':') colon(color);
|
||||
else nocolon();
|
||||
|
||||
}
|
||||
|
||||
void noclock() {
|
||||
for (int led = 0; led < clock.numPixels(); led++) {
|
||||
clock.setPixelColor(led, 0);
|
||||
}
|
||||
clock.show();
|
||||
}
|
||||
|
||||
|
||||
void colon(uint32_t color) {
|
||||
for (int led = 0; led < SEPLEN; led++) {
|
||||
int currentLed = SEGLEN * 14 + led;
|
||||
clock.setPixelColor(currentLed, color);
|
||||
}
|
||||
clock.show();
|
||||
}
|
||||
|
||||
void nocolon() {
|
||||
for (int led = 0; led < SEPLEN; led++) {
|
||||
int currentLed = SEGLEN * 14 + led;
|
||||
clock.setPixelColor(currentLed, 0);
|
||||
}
|
||||
clock.show();
|
||||
}
|
||||
|
||||
void fillNumber(int position, int digit, uint32_t color) {
|
||||
int offset = 0;
|
||||
if (position > 3)return;
|
||||
if (position < 0)return;
|
||||
if (position > 1) offset = SEPLEN;
|
||||
|
||||
for (int seg = 0; seg < 7; seg++) {
|
||||
for (int led = 0; led < SEGLEN; led++) {
|
||||
int currentLed = position * 5 * 7 + seg * 5 + led + offset;
|
||||
if (digits[digit][seg] == 1) {
|
||||
clock.setPixelColor(currentLed, color);
|
||||
} else {
|
||||
clock.setPixelColor(currentLed, clock.Color(0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void countUp(uint32_t color, int wait) {
|
||||
fillNumber(0, 8, clock.Color(0,0,0));
|
||||
|
||||
for (int num3 = 0; num3 < 10; num3++) {
|
||||
fillNumber(1, num3, color);
|
||||
|
||||
for (int num2 = 0; num2 < 10; num2++) {
|
||||
fillNumber(2, num2, color);
|
||||
|
||||
for (int num1 = 0; num1 < 10; num1++) {
|
||||
fillNumber(3, num1, color);
|
||||
|
||||
clock.show();
|
||||
delay(wait);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user