Skip to content

Commit

Permalink
Stable release : laboite v3.4 (modular code in progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaultier committed Mar 31, 2015
1 parent 44983eb commit e4d28ae
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 79 deletions.
156 changes: 98 additions & 58 deletions laboite.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
laboite v3.2.23.2.2
laboite v3.4
This Arduino firmware is part of laboite project https://laboite.cc/help
It is a connected device displaying a lot of information (A LOT !) coming from an
Internet server with a laboite web app deployed (e.g. https://laboite.cc/ ).
Key Features:
* Connects to laboite-webapp to retrieve apps data
* Connects to laboite-webapp API to retrieve data
* Parse the json received and display datas on the LED matrix
* Indoor temperature (optionnal, uncomment SENSORS to enable it)
* Automatic screen brightness adjusting (optionnal, uncomment SENSORS to enable it)
* Stop scrolling function (optionnal, uncomment SENSORS to enable it)
Expand All @@ -22,41 +23,37 @@
* Coffees
* Emails
* RATP
* Agenda
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* or ESP8266 Wifi module (not stable yet) attached to pins 0 and 1
* Ethernet shield attached to pins 10, 11, 12, 13 (Arduino Yún support from v3.4)
* Sure Electronics 3216 LED matrix attached to pins 4, 5, 6, 7
* TinkerKit LDR, Thermistor and Button modules on I0, I1, I2 (optionnal, uncomment SENSORS to enable it)
* LDR, Thermistor and Button modules on A0, A1, A2 (optionnal, uncomment SENSORS to enable it)
created 15 Dec 2011
by Baptiste Gaultier and Tanguy Ropitault
modified 30 Dec 2014
modified 31 Mar 2015
by Baptiste Gaultier
This code is in the public domain.
*/

// uncomment if you want to enable debug
//#define DEBUG
// uncomment if you want to enable Ethernet
#define ETHERNET
// uncomment if you want to enable dotmatrix
#define HT1632C
// uncomment if you want to enable TinkerKit! sensors
//#define TINKERKIT
// uncomment if you want to enable classic sensors
//#define SENSORS
// uncomment if you want to enable the AVR Watchdog
//#define WATCHDOG
#define WATCHDOG

#ifdef ETHERNET
#include <SPI.h>
#include <Ethernet.h>
#endif
#ifdef TINKERKIT
#include <TinkerKit.h>
#endif
#ifdef HT1632C
#include <ht1632c.h>
#endif
Expand All @@ -68,12 +65,6 @@
// enter a MAC address and IP address for your controller below.
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE5, 0x91 };

// fill in an available IP address on your network here,
// for auto-configuration:
IPAddress ip(192, 168, 2, 64);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(192, 168, 2, 1);

// initialize the library instance:
EthernetClient client;
#endif
Expand All @@ -85,74 +76,116 @@ char apikey[] = "964de680"; // your device API key

String currentLine = ""; // string to hold the text from server

// variables used to display infos
// Modular Apps code
// (uncomment only the apps you need, otherwise the sketch will be too big)
#define ENERGY
#define MESSAGES
#define COFFEES
#define AGENDA


// Variables used to display infos

char hour[3];
char minutes[3];
char bus[3];
char bikes[3];
char emails[3];

byte todayIcon;
char temperature[3];
byte tomorrowIcon;
char low[3];
char high[3];
byte color;

#ifdef SENSORS
char indoorTemperatureString[3];
byte indoorTemperature;
#endif
#ifdef TINKERKIT
char indoorTemperatureString[3];
byte indoorTemperature;
#endif
char temperature[3];
char low[3];
char high[3];

char bus[3];

char bikes[3];

#ifdef ENERGY
byte energy[7];
#endif

#ifdef EMAILS
char emails[3];
#endif

#ifdef MESSAGES
char message[140];
#endif

#ifdef COFFEES
char coffees[3];
#endif

char eventStart[5];
char eventSummary[64];

// parser variables
// Parser variables
boolean readingTime = false;
boolean readingBus = false;
boolean readingBikes = false;
boolean readingEmails = false;
boolean readingCoffees = false;

boolean readingTodayIcon = false;
boolean readingTemperature = false;
boolean readingTomorrowIcon = false;
boolean readingLow = false;
boolean readingHigh = false;

boolean readingBus = false;
boolean readingBikes = false;

#ifdef ENERGY
boolean readingDay0 = false;
boolean readingDay1 = false;
boolean readingDay2 = false;
boolean readingDay3 = false;
boolean readingDay4 = false;
boolean readingDay5 = false;
boolean readingDay6 = false;
#endif

boolean readingMessage = false;

#ifdef COFFEES
boolean readingCoffees = false;
#endif

boolean readingEmails = false;

boolean readingEventStart = false;
boolean readingEventSummary = false;

// apps variables

// Apps variables

boolean timeEnabled = false;
boolean busEnabled = false;
boolean bikesEnabled = false;
boolean emailsEnabled = false;
boolean weatherEnabled = false;
#ifdef ENERGY
boolean energyEnabled = false;
#endif
boolean messagesEnabled = false;

#ifdef TINKERKIT
TKLightSensor ldr(I0); // ldr used to adjust dotmatrix brightness
TKThermistor therm(I1); // thermistor used for indoor temperature
TKButton button(I2); // pushbutton used to start/stop scrolling
#ifdef COFFEES
boolean coffeesEnabled = false;
#endif
#ifdef AGENDA
boolean agendaEnabled = false;
#endif

#ifdef SENSORS
// constants won't change. They're used here to
// Sensors constants won't change. They're used here to
// set pin numbers:
const byte ldrPin = A0; // ldr used to adjust dotmatrix brightness
const byte thermistorPin = A1; // thermistor used for indoor temperature
const byte buttonPin = A2; // pushbutton used to start/stop scrolling

// Sensors variables
int brightnessValue = 0; // value read from the LDR
int previousBrightnessValue = 512; // previous value of brightness
#endif

#ifdef HT1632C
Expand All @@ -176,9 +209,14 @@ uint16_t busSprite[9] = { 0x00fc, 0x0186, 0x01fe, 0x0102, 0x0102, 0x01fe, 0x017a
uint16_t bikeSprite[9] = { 0x020c, 0x0102, 0x008c, 0x00f8, 0x078e, 0x0ab9, 0x0bd5, 0x0891, 0x070e};
// emails app sprite:
uint16_t emailSprite[6] = { 0x00fe, 0x0145, 0x0129, 0x0111, 0x0101, 0x00fe};

int brightnessValue = 0; // value read from the LDR
int previousBrightnessValue = 512; // previous value of brightness
#ifdef COFFEES
// coffees app sprite
uint16_t coffeeSprite[8] = {0x4800, 0x2400, 0x4800, 0xff00, 0x8500, 0x8600, 0x8400, 0x7800};
#endif
#ifdef AGENDA
// agenda app sprite
uint16_t calendarSprite[8] = { 0b01111111, 0b01111111, 0b01000001, 0b01001001, 0b01001001, 0b01001001, 0b01000001, 0b01111111 };
#endif

boolean scrolling = true; // value modified when button is pressed

Expand All @@ -196,18 +234,12 @@ void setup() {

// display a welcome message:
#ifdef DEBUG
Serial.println("laboite v3.2.2 starting...");
Serial.println("laboite v3.4 starting...");
#endif

// attempt a DHCP connection:
#ifdef ETHERNET
if (!Ethernet.begin(mac)) {
// if DHCP fails, start with a hard-coded address:
#ifdef DEBUG
Serial.println("failed to get an IP address using DHCP, trying manually");
#endif
Ethernet.begin(mac, ip, subnet);
}
Ethernet.begin(mac);
#endif

#ifdef DEBUG
Expand Down Expand Up @@ -242,7 +274,6 @@ void setup() {
}



void loop()
{
if (client.connected()) {
Expand All @@ -266,20 +297,33 @@ void loop()
#endif


for (int x = 32; x > -130; x--) {
for (int x = 32; x > -162; x--) {
adjustBrightness();

// scroll through apps
scrollFirstPanel(x);
scrollSecondPanel(x);
scrollThirdPanel(x);
scrollFourthPanel(x);
#ifdef AGENDA
if(agendaEnabled)
scrollFifthPanel(x);
else {
if(x == -129) {
dotmatrix.sendframe();
break;
}
}

dotmatrix.sendframe();

delay(30);

}
#endif
#ifdef MESSAGES
scrollSixthPanel();
#endif

#ifdef TINKERKIT
if(button.read())
Expand Down Expand Up @@ -307,10 +351,6 @@ void loop()
#endif
delay(requestInterval/4);
}
#ifdef TINKERKIT
if(button.read())
scrolling = !scrolling;
#endif
#ifdef SENSORS
if (digitalRead(buttonPin) == HIGH)
scrolling = !scrolling;
Expand Down
Loading

0 comments on commit e4d28ae

Please sign in to comment.