Lamp::Lamp(unsigned char ledPin, unsigned char audioPin) { _menuIndex =0x0; _menuDepth = 0; this->lpin = ledPin; this->audPin = audioPin; this->LEDCycleRising = true; this->LEDPWM = 0; this->cycleStep = 1; this->_sleeping = false; this->_lampOn = true; fadeTimer = Metro(1); _alarming = false; tAlarmStarted = 128; //Default Values if Lamp is starting for the first time if (!isInit()) { setDisplayMode(0x1); setAlarmAM(true); setAlarmHour(7); setAlarmMin(30); setAlarmOn(false); //setLCDBrightness(255); setLampBrightness(128); setCycleFadeTime(15); setCycleHoldTime(15); setCycleSteps(15); setRandomFadeTime(15); setRandomHoldTime(15); setColorHue(150); setColorSat(150); } drawMenu(menuPosition()); }
int main() { TransportationSystem ratt = TransportationSystem(); Station maria = Station("maria"); Station cluj = Station("cluj"); Station traian = Station("traian"); Station buzias = Station("buzias"); Station aem = Station("aem"); Segment aem_cluj = Segment(&aem, &cluj, 2); Segment aem_maria = Segment(&aem, &maria, 2); Segment maria_cluj = Segment(&maria, &cluj, 10); Segment maria_buzias = Segment(&maria, &buzias, 1); Segment cluj_buzias = Segment(&cluj, &buzias, 5); Segment cluj_traian = Segment(&cluj, &traian, 5); Segment traian_buzias = Segment(&traian, &buzias, 3); Metro tram8 = Metro("8"); tram8.addSegment(&maria_cluj); tram8.addSegment(&maria_buzias); tram8.addSegment(&cluj_buzias); tram8.addSegment(&cluj_traian); tram8.addSegment(&traian_buzias); tram8.addSegment(&aem_cluj); tram8.addSegment(&aem_maria); ratt.addMetro(&tram8); ratt.setRoutingStrategy("DIJSTRA"); ratt.findRoute(aem, traian); return 0; }
#include "Metro.h" //Include Metro library #include "MLX90316.h" // Include MLX90316 library // calibration #include "WProgram.h" void setup(); void loop(); void Servo360(int deg); int north = 298; // setup sensor int pinSS = 5; int pinSCK = 3; int pinMOSI = 4; int ii; Metro mlxMetro = Metro(40); // 25 Hz update freq, mirite? MLX90316 mlx_1 = MLX90316(); // sensor values int a1,v1,v1a; void setup(){ pinMode(12,OUTPUT); Serial.begin(9600); mlx_1.attach(pinSS,pinSCK, pinMOSI ); } void loop(){ if (mlxMetro.check() == 1) { int sens = mlx_1.readAngle(); Serial.print(sens);
#define font_width 12 uint8_t sch = 0; bool freq_flag = 0; extern AudioAnalyzeFFT256IQ myFFT; float uv, uvold, dbuv, dbm, s;// microvolts, db-microvolts, s-units, volts, dbm, sold = old S-meter value, deltas = abs difference between sold and s float dbmold = 0; char string[80]; int le, bwhelp, left, lsb; int pixelold[160] = {0}; int pixelnew[160]; int oldnotchF = 10000; uint8_t digits_old [] = {9,9,9,9,9,9,9,9,9,9}; Metro Smetertimer = Metro(50); //extern AudioAnalyzeFFT256 myFFT; // FFT for Spectrum Display void init_display(void) { tft.initR(INITR_BLACKTAB); } void setup_display(void) { // initialize the LCD display // tft.init(); // tft.initR(INITR_BLACKTAB); // initialize a S6D02A1S chip, black tab tft.setRotation(1); tft.fillScreen(BLACK); //BLACK); //tft.fillRect(0, pos, 160, 128-pos, BLACK); // erase old string
enum type_alarmState { off, // system idle wait_on, // delay before running (delai de sortie maison) on, // system is running detection, // movement detected before_sirene,// delay before sirene (delai d'entrée dans maison) ring_sirene // sirene is ringing }; // --- variables --- type_alarmState alarmState = off; type_alarmState next_alarmState = alarmState; uint8_t printPositionPIN = 0; boolean passCorrect = false; boolean sensorDetection = false; Metro wait_on_timer = Metro(wait_on_delay); Metro before_sirene_timer = Metro(before_sirene_delay); Metro ring_sirene_timer = Metro(ring_sirene_delay); Password pwd = Password("123"); // définition du mot de passe // --- setup Keypad --- char keys[ROWS][COLS] = // { // {'1','2','3','A'}, // {'4','5','6','B'}, // configuration {'7','8','9','C'}, // du clavier {'*','0','#','D'} // }; // byte rowPins[ROWS] = {9, 8, 7, 6}; // byte colPins[COLS] = {5, 4, 3, 2}; // Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); //
#include <Arduino.h> #include <Metro.h> #define encoder0PinA 2 #define encoder0PinB 3 ros::NodeHandle nh; int pinAState = 0; int pinAStateOld = 0; int pinBState = 0; int pinBStateOld = 0; volatile long encoder0Pos = 0; volatile long unknownvalue = 0; Metro mainTimer = Metro(10); void doEncoder() { // encoder0Pos++; pinAState = digitalRead(2); pinBState = digitalRead(3); if (pinAState == 0 && pinBState == 0) { if (pinAStateOld == 1 && pinBStateOld == 0) // forward encoder0Pos ++; if (pinAStateOld == 0 && pinBStateOld == 1) // reverse encoder0Pos --; if (pinAStateOld == 1 && pinBStateOld == 1) // unknown unknownvalue ++; if (pinAStateOld == 0 && pinBStateOld == 0) // unknown
#include <EEPROM.h> #include <Wire.h> #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif #include "lamp.h" #pragma region Core Metro idleMetro = Metro(1000); Metro clkMetro = Metro(500); Lamp::Lamp(unsigned char ledPin, unsigned char audioPin) { _menuIndex =0x0; _menuDepth = 0; this->lpin = ledPin; this->audPin = audioPin; this->LEDCycleRising = true; this->LEDPWM = 0; this->cycleStep = 1; this->_sleeping = false; this->_lampOn = true; fadeTimer = Metro(1);
{'7','8','9','C'}, {'*','0','#','D'} }; byte rowPins[ROWS] = {9, 8, 7, 6}; byte colPins[COLS] = {5, 4, 3, 2}; Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); //prog state typedef enum{ MODIFPWD, NORMAL } progState; progState stateProgram; typedef enum{ DEBUT, WAIT_OLD_PWD, WAIT_NEW_PWD_1, WAIT_NEW_PWD_2, NA } modifPwdState; modifPwdState statePwd; // tempo inactivite const int DELAY_INACTIF = 7 * 1000; Metro delayInactif = Metro(DELAY_INACTIF); bool relayState = false; chaine4 pwd_admin; // never erased, constant chaine4 pwd_menu; // to change user pwd chaine4 pwd_user; // user pwd, can be changed chaine4 pwd_buffer; chaine4 pwd_buffer2; void setup(){ Serial.begin(9600); chaine4Init(&pwd_admin); chaine4Init(&pwd_user); chaine4Init(&pwd_menu); chaine4Init(&pwd_buffer);
void loop(); uint32_t pumpkin_1[1][25] = { {0x00000400, 0x00000600, 0x00001C00, 0x00003800, 0x00007C00, 0x0001FF00, 0x0007FFC0, 0x000FFFE0, 0x001CFE70, 0x003E38F8, 0x003E38F8, 0x007FFFFC, 0x007FEFFC, 0x007FC7FC, 0x007FFFFC, 0x007FFFFC, 0x0039FF38, 0x003C4A78, 0x003E00F8, 0x001F33F0, 0x000FFFE0, 0x0003FFC0, 0x0001FE00, 0x00000000, 0x00000000} }; uint32_t pumpkin_2[1][25] = { {0x00000400, 0x00000600, 0x00001C00, 0x00003800, 0x00007C00, 0x0001FF00, 0x0007FFC0, 0x000FFFE0, 0x001CFE70, 0x003E38F8, 0x003E38F8, 0x007FFFFC, 0x007FEFFC, 0x007FC7FC, 0x007FFFFC, 0x0079FF3C, 0x00384A38, 0x003C0078, 0x003C00F8, 0x001F01F0, 0x000FB3E0, 0x0003FFC0, 0x0001FE00, 0x00000000, 0x00000000} }; uint32_t ghost_x[1][25] = { {0x00000000, 0x00000000, 0x0001FF80, 0x0003FFC0, 0x0007FFE0, 0x000FFFF0, 0x0019F3F8, 0x0010E1F8, 0x001870FC, 0x001C78FC, 0x001C78FC, 0x001870FC, 0x0010E1FC, 0x001FFFFC, 0x001FFFFC, 0x001FFFFC, 0x001FFFFC, 0x001FFFFC, 0x001FFFFC, 0x001F7F7C, 0x001E3E3C, 0x001C1C1C, 0x00000000, 0x00000000, 0x00000000} }; int frame = 1; int row; int scene = 0; Metro frame_tempo = Metro(100); Metro scene_tempo = Metro(10000); // declare frame buffer Peggy2 peggy; Peggy2 ghost; Peggy2 pumpkin1; Peggy2 pumpkin2; void setup() // run once, when the sketch starts { peggy.HardwareInit(); for (row = 0; row < 25; row++) { pumpkin1.WriteRow(row, pumpkin_1[0][row]); pumpkin2.WriteRow(row, pumpkin_2[0][row]);