Mercurial > code > home > repos > homeauto
changeset 1291:c1b0813372cc
move to /my/proj/hardware/busyboxArduino. hardware is still around and this has notes on how to use it.
Ignore-this: 7743f57abef17980c595b1686abf646a
darcs-hash:75f747175229c26222b107b64458d0c01845e17d
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 21 Apr 2019 01:26:58 -0700 |
parents | 4fa09ec19c86 |
children | e136ee9feffd |
files | service/busyboxArduino/DFR_Key.cpp service/busyboxArduino/DFR_Key.h service/busyboxArduino/IRremote/IRremote.cpp service/busyboxArduino/IRremote/IRremote.h service/busyboxArduino/IRremote/IRremoteInt.h service/busyboxArduino/IRremote/LICENSE.txt service/busyboxArduino/IRremote/examples/IRrecord/IRrecord.ino service/busyboxArduino/IRremote/examples/IRrecvDemo/IRrecvDemo.ino service/busyboxArduino/IRremote/examples/IRrecvDump/IRrecvDump.ino service/busyboxArduino/IRremote/examples/IRrelay/IRrelay.ino service/busyboxArduino/IRremote/examples/IRsendDemo/IRsendDemo.ino service/busyboxArduino/IRremote/examples/IRtest/IRtest.ino service/busyboxArduino/IRremote/examples/IRtest2/IRtest2.ino service/busyboxArduino/IRremote/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino service/busyboxArduino/IRremote/keywords.txt service/busyboxArduino/IRremote/readme service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/FastIO.cpp service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/FastIO.h service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/I2CIO.cpp service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/I2CIO.h service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LCD.cpp service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LCD.h service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal.cpp service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal.h service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_I2C.cpp service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_I2C.h service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR.cpp service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR.h service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR2W.cpp service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR2W.h service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR3W.cpp service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR3W.h service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/HelloWorld_4bit/HelloWorld_4bit.pde service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/HelloWorld_SR/HelloWorld_SR.pde service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/HelloWorld_i2c/HelloWorld_i2c.pde service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/LCDiSpeed/LCDiSpeed.pde service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/LCDiSpeed/LCDiSpeed.txt service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/SerialDisplay/SerialDisplay.pde service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/i2cLCDextraIO/i2cLCDextraIO.pde service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/i2cLCDextraIO_tempLeonardo/i2cLCDextraIO_tempLeonardo.ino service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/performanceLCD/performanceLCD.pde service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/keywords.txt service/busyboxArduino/busybox.py service/busyboxArduino/main.ino service/busyboxArduino/makefile service/busyboxArduino/pydeps |
diffstat | 46 files changed, 0 insertions(+), 9137 deletions(-) [+] |
line wrap: on
line diff
--- a/service/busyboxArduino/DFR_Key.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -// rewritten from distro version by drewp 2015-01-04 - -#include "Arduino.h" -#include "DFR_Key.h" - -static int DEFAULT_KEY_PIN = 0; -static int DEFAULT_THRESHOLD = 5; - -// Updated for my board -static int UPKEY_ARV = 103; //that's read "analogue read value" -static int DOWNKEY_ARV = 266; -static int LEFTKEY_ARV = 426; -static int RIGHTKEY_ARV = 0; -static int SELKEY_ARV = 668; -static int NOKEY_ARV = 1023; - -DFR_Key::DFR_Key() -{ - _refreshRate = 10; - _keyPin = DEFAULT_KEY_PIN; - _threshold = DEFAULT_THRESHOLD; - _keyIn = NO_KEY; - _curInput = NO_KEY; - _curKey = NO_KEY; - _prevInput = NO_KEY; - _prevKey = NO_KEY; - _oldTime = 0; -} - -int DFR_Key::getKey() -{ - if (millis() < _oldTime + _refreshRate) { - return SAMPLE_WAIT; - } - - _prevInput = _curInput; - _curInput = analogRead(_keyPin); - _oldTime = millis(); - - if (_curInput != _prevInput) { - // We could be in the middle of a key change - return SAMPLE_WAIT; - } - - _prevKey = _curKey; - - int curLo = _curInput - _threshold; - int curHi = _curInput + _threshold; - if ( curHi > UPKEY_ARV && curLo < UPKEY_ARV) _curKey = UP_KEY; - else if ( curHi > DOWNKEY_ARV && curLo < DOWNKEY_ARV) _curKey = DOWN_KEY; - else if ( curHi > RIGHTKEY_ARV && curLo < RIGHTKEY_ARV) _curKey = RIGHT_KEY; - else if ( curHi > LEFTKEY_ARV && curLo < LEFTKEY_ARV) _curKey = LEFT_KEY; - else if ( curHi > SELKEY_ARV && curLo < SELKEY_ARV) _curKey = SELECT_KEY; - else _curKey = NO_KEY; - - return _curKey; -} - -void DFR_Key::setRate(int rate) -{ - _refreshRate = rate; -}
--- a/service/busyboxArduino/DFR_Key.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -#ifndef DFR_Key_h -#define DFR_Key_h - -#include "Arduino.h" - -#define SAMPLE_WAIT -1 -#define NO_KEY 0 -#define UP_KEY 3 -#define DOWN_KEY 4 -#define LEFT_KEY 2 -#define RIGHT_KEY 5 -#define SELECT_KEY 1 - -class DFR_Key -{ - public: - DFR_Key(); - int getKey(); - void setRate(int); - private: - int _refreshRate; - int _keyPin; - int _threshold; - int _keyIn; - int _curInput; - int _curKey; - int _prevInput; - int _prevKey; - boolean _change; - unsigned long _oldTime; -}; - -#endif \ No newline at end of file
--- a/service/busyboxArduino/IRremote/IRremote.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1154 +0,0 @@ -/* - * IRremote - * Version 0.11 August, 2009 - * Copyright 2009 Ken Shirriff - * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html - * - * Modified by Paul Stoffregen <paul@pjrc.com> to support other boards and timers - * Modified by Mitra Ardron <mitra@mitra.biz> - * Added Sanyo and Mitsubishi controllers - * Modified Sony to spot the repeat codes that some Sony's send - * - * Interrupt code based on NECIRrcv by Joe Knapp - * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 - * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ - * - * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) - * LG added by Darryl Smith (based on the JVC protocol) - */ - -#include "IRremote.h" -#include "IRremoteInt.h" - -// Provides ISR -#include <avr/interrupt.h> - -volatile irparams_t irparams; - -// These versions of MATCH, MATCH_MARK, and MATCH_SPACE are only for debugging. -// To use them, set DEBUG in IRremoteInt.h -// Normally macros are used for efficiency -#ifdef DEBUG -int MATCH(int measured, int desired) { - Serial.print("Testing: "); - Serial.print(TICKS_LOW(desired), DEC); - Serial.print(" <= "); - Serial.print(measured, DEC); - Serial.print(" <= "); - Serial.println(TICKS_HIGH(desired), DEC); - return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired); -} - -int MATCH_MARK(int measured_ticks, int desired_us) { - Serial.print("Testing mark "); - Serial.print(measured_ticks * USECPERTICK, DEC); - Serial.print(" vs "); - Serial.print(desired_us, DEC); - Serial.print(": "); - Serial.print(TICKS_LOW(desired_us + MARK_EXCESS), DEC); - Serial.print(" <= "); - Serial.print(measured_ticks, DEC); - Serial.print(" <= "); - Serial.println(TICKS_HIGH(desired_us + MARK_EXCESS), DEC); - return measured_ticks >= TICKS_LOW(desired_us + MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS); -} - -int MATCH_SPACE(int measured_ticks, int desired_us) { - Serial.print("Testing space "); - Serial.print(measured_ticks * USECPERTICK, DEC); - Serial.print(" vs "); - Serial.print(desired_us, DEC); - Serial.print(": "); - Serial.print(TICKS_LOW(desired_us - MARK_EXCESS), DEC); - Serial.print(" <= "); - Serial.print(measured_ticks, DEC); - Serial.print(" <= "); - Serial.println(TICKS_HIGH(desired_us - MARK_EXCESS), DEC); - return measured_ticks >= TICKS_LOW(desired_us - MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS); -} -#else -int MATCH(int measured, int desired) {return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);} -int MATCH_MARK(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us + MARK_EXCESS));} -int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us - MARK_EXCESS));} -// Debugging versions are in IRremote.cpp -#endif - -void IRsend::sendNEC(unsigned long data, int nbits) -{ - enableIROut(38); - mark(NEC_HDR_MARK); - space(NEC_HDR_SPACE); - for (int i = 0; i < nbits; i++) { - if (data & TOPBIT) { - mark(NEC_BIT_MARK); - space(NEC_ONE_SPACE); - } - else { - mark(NEC_BIT_MARK); - space(NEC_ZERO_SPACE); - } - data <<= 1; - } - mark(NEC_BIT_MARK); - space(0); -} - -void IRsend::sendSony(unsigned long data, int nbits) { - enableIROut(40); - mark(SONY_HDR_MARK); - space(SONY_HDR_SPACE); - data = data << (32 - nbits); - for (int i = 0; i < nbits; i++) { - if (data & TOPBIT) { - mark(SONY_ONE_MARK); - space(SONY_HDR_SPACE); - } - else { - mark(SONY_ZERO_MARK); - space(SONY_HDR_SPACE); - } - data <<= 1; - } -} - -void IRsend::sendRaw(unsigned int buf[], int len, int hz) -{ - enableIROut(hz); - for (int i = 0; i < len; i++) { - if (i & 1) { - space(buf[i]); - } - else { - mark(buf[i]); - } - } - space(0); // Just to be sure -} - -// Note: first bit must be a one (start bit) -void IRsend::sendRC5(unsigned long data, int nbits) -{ - enableIROut(36); - data = data << (32 - nbits); - mark(RC5_T1); // First start bit - space(RC5_T1); // Second start bit - mark(RC5_T1); // Second start bit - for (int i = 0; i < nbits; i++) { - if (data & TOPBIT) { - space(RC5_T1); // 1 is space, then mark - mark(RC5_T1); - } - else { - mark(RC5_T1); - space(RC5_T1); - } - data <<= 1; - } - space(0); // Turn off at end -} - -// Caller needs to take care of flipping the toggle bit -void IRsend::sendRC6(unsigned long data, int nbits) -{ - enableIROut(36); - data = data << (32 - nbits); - mark(RC6_HDR_MARK); - space(RC6_HDR_SPACE); - mark(RC6_T1); // start bit - space(RC6_T1); - int t; - for (int i = 0; i < nbits; i++) { - if (i == 3) { - // double-wide trailer bit - t = 2 * RC6_T1; - } - else { - t = RC6_T1; - } - if (data & TOPBIT) { - mark(t); - space(t); - } - else { - space(t); - mark(t); - } - - data <<= 1; - } - space(0); // Turn off at end -} -void IRsend::sendPanasonic(unsigned int address, unsigned long data) { - enableIROut(35); - mark(PANASONIC_HDR_MARK); - space(PANASONIC_HDR_SPACE); - - for(int i=0;i<16;i++) - { - mark(PANASONIC_BIT_MARK); - if (address & 0x8000) { - space(PANASONIC_ONE_SPACE); - } else { - space(PANASONIC_ZERO_SPACE); - } - address <<= 1; - } - for (int i=0; i < 32; i++) { - mark(PANASONIC_BIT_MARK); - if (data & TOPBIT) { - space(PANASONIC_ONE_SPACE); - } else { - space(PANASONIC_ZERO_SPACE); - } - data <<= 1; - } - mark(PANASONIC_BIT_MARK); - space(0); -} -void IRsend::sendJVC(unsigned long data, int nbits, int repeat) -{ - enableIROut(38); - data = data << (32 - nbits); - if (!repeat){ - mark(JVC_HDR_MARK); - space(JVC_HDR_SPACE); - } - for (int i = 0; i < nbits; i++) { - if (data & TOPBIT) { - mark(JVC_BIT_MARK); - space(JVC_ONE_SPACE); - } - else { - mark(JVC_BIT_MARK); - space(JVC_ZERO_SPACE); - } - data <<= 1; - } - mark(JVC_BIT_MARK); - space(0); -} - -void IRsend::sendSAMSUNG(unsigned long data, int nbits) -{ - enableIROut(38); - mark(SAMSUNG_HDR_MARK); - space(SAMSUNG_HDR_SPACE); - for (int i = 0; i < nbits; i++) { - if (data & TOPBIT) { - mark(SAMSUNG_BIT_MARK); - space(SAMSUNG_ONE_SPACE); - } - else { - mark(SAMSUNG_BIT_MARK); - space(SAMSUNG_ZERO_SPACE); - } - data <<= 1; - } - mark(SAMSUNG_BIT_MARK); - space(0); -} - -void IRsend::mark(int time) { - // Sends an IR mark for the specified number of microseconds. - // The mark output is modulated at the PWM frequency. - TIMER_ENABLE_PWM; // Enable pin 3 PWM output - if (time > 0) delayMicroseconds(time); -} - -/* Leave pin off for time (given in microseconds) */ -void IRsend::space(int time) { - // Sends an IR space for the specified number of microseconds. - // A space is no output, so the PWM output is disabled. - TIMER_DISABLE_PWM; // Disable pin 3 PWM output - if (time > 0) delayMicroseconds(time); -} - -void IRsend::enableIROut(int khz) { - // Enables IR output. The khz value controls the modulation frequency in kilohertz. - // The IR output will be on pin 3 (OC2B). - // This routine is designed for 36-40KHz; if you use it for other values, it's up to you - // to make sure it gives reasonable results. (Watch out for overflow / underflow / rounding.) - // TIMER2 is used in phase-correct PWM mode, with OCR2A controlling the frequency and OCR2B - // controlling the duty cycle. - // There is no prescaling, so the output frequency is 16MHz / (2 * OCR2A) - // To turn the output on and off, we leave the PWM running, but connect and disconnect the output pin. - // A few hours staring at the ATmega documentation and this will all make sense. - // See my Secrets of Arduino PWM at http://arcfn.com/2009/07/secrets-of-arduino-pwm.html for details. - - - // Disable the Timer2 Interrupt (which is used for receiving IR) - TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt - - pinMode(TIMER_PWM_PIN, OUTPUT); - digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low - - // COM2A = 00: disconnect OC2A - // COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted - // WGM2 = 101: phase-correct PWM with OCRA as top - // CS2 = 000: no prescaling - // The top value for the timer. The modulation frequency will be SYSCLOCK / 2 / OCR2A. - TIMER_CONFIG_KHZ(khz); -} - -IRrecv::IRrecv(int recvpin) -{ - irparams.recvpin = recvpin; - irparams.blinkflag = 0; -} - -// initialization -void IRrecv::enableIRIn() { - cli(); - // setup pulse clock timer interrupt - //Prescale /8 (16M/8 = 0.5 microseconds per tick) - // Therefore, the timer interval can range from 0.5 to 128 microseconds - // depending on the reset value (255 to 0) - TIMER_CONFIG_NORMAL(); - - //Timer2 Overflow Interrupt Enable - TIMER_ENABLE_INTR; - - TIMER_RESET; - - sei(); // enable interrupts - - // initialize state machine variables - irparams.rcvstate = STATE_IDLE; - irparams.rawlen = 0; - - // set pin modes - pinMode(irparams.recvpin, INPUT); -} - -// enable/disable blinking of pin 13 on IR processing -void IRrecv::blink13(int blinkflag) -{ - irparams.blinkflag = blinkflag; - if (blinkflag) - pinMode(BLINKLED, OUTPUT); -} - -// TIMER2 interrupt code to collect raw data. -// Widths of alternating SPACE, MARK are recorded in rawbuf. -// Recorded in ticks of 50 microseconds. -// rawlen counts the number of entries recorded so far. -// First entry is the SPACE between transmissions. -// As soon as a SPACE gets long, ready is set, state switches to IDLE, timing of SPACE continues. -// As soon as first MARK arrives, gap width is recorded, ready is cleared, and new logging starts -ISR(TIMER_INTR_NAME) -{ - TIMER_RESET; - - uint8_t irdata = (uint8_t)digitalRead(irparams.recvpin); - - irparams.timer++; // One more 50us tick - if (irparams.rawlen >= RAWBUF) { - // Buffer overflow - irparams.rcvstate = STATE_STOP; - } - switch(irparams.rcvstate) { - case STATE_IDLE: // In the middle of a gap - if (irdata == MARK) { - if (irparams.timer < GAP_TICKS) { - // Not big enough to be a gap. - irparams.timer = 0; - } - else { - // gap just ended, record duration and start recording transmission - irparams.rawlen = 0; - irparams.rawbuf[irparams.rawlen++] = irparams.timer; - irparams.timer = 0; - irparams.rcvstate = STATE_MARK; - } - } - break; - case STATE_MARK: // timing MARK - if (irdata == SPACE) { // MARK ended, record time - irparams.rawbuf[irparams.rawlen++] = irparams.timer; - irparams.timer = 0; - irparams.rcvstate = STATE_SPACE; - } - break; - case STATE_SPACE: // timing SPACE - if (irdata == MARK) { // SPACE just ended, record it - irparams.rawbuf[irparams.rawlen++] = irparams.timer; - irparams.timer = 0; - irparams.rcvstate = STATE_MARK; - } - else { // SPACE - if (irparams.timer > GAP_TICKS) { - // big SPACE, indicates gap between codes - // Mark current code as ready for processing - // Switch to STOP - // Don't reset timer; keep counting space width - irparams.rcvstate = STATE_STOP; - } - } - break; - case STATE_STOP: // waiting, measuring gap - if (irdata == MARK) { // reset gap timer - irparams.timer = 0; - } - break; - } - - if (irparams.blinkflag) { - if (irdata == MARK) { - BLINKLED_ON(); // turn pin 13 LED on - } - else { - BLINKLED_OFF(); // turn pin 13 LED off - } - } -} - -void IRrecv::resume() { - irparams.rcvstate = STATE_IDLE; - irparams.rawlen = 0; -} - - - -// Decodes the received IR message -// Returns 0 if no data ready, 1 if data ready. -// Results of decoding are stored in results -int IRrecv::decode(decode_results *results) { - results->rawbuf = irparams.rawbuf; - results->rawlen = irparams.rawlen; - if (irparams.rcvstate != STATE_STOP) { - return ERR; - } -#ifdef DEBUG - Serial.println("Attempting NEC decode"); -#endif - if (decodeNEC(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting Sony decode"); -#endif - if (decodeSony(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting Sanyo decode"); -#endif - if (decodeSanyo(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting Mitsubishi decode"); -#endif - if (decodeMitsubishi(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting RC5 decode"); -#endif - if (decodeRC5(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting RC6 decode"); -#endif - if (decodeRC6(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting Panasonic decode"); -#endif - if (decodePanasonic(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting LG decode"); -#endif - if (decodeLG(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting JVC decode"); -#endif - if (decodeJVC(results)) { - return DECODED; - } -#ifdef DEBUG - Serial.println("Attempting SAMSUNG decode"); -#endif - if (decodeSAMSUNG(results)) { - return DECODED; - } - // decodeHash returns a hash on any input. - // Thus, it needs to be last in the list. - // If you add any decodes, add them before this. - if (decodeHash(results)) { - return DECODED; - } - // Throw away and start over - resume(); - return ERR; -} - -// NECs have a repeat only 4 items long -long IRrecv::decodeNEC(decode_results *results) { - long data = 0; - int offset = 1; // Skip first space - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], NEC_HDR_MARK)) { - return ERR; - } - offset++; - // Check for repeat - if (irparams.rawlen == 4 && - MATCH_SPACE(results->rawbuf[offset], NEC_RPT_SPACE) && - MATCH_MARK(results->rawbuf[offset+1], NEC_BIT_MARK)) { - results->bits = 0; - results->value = REPEAT; - results->decode_type = NEC; - return DECODED; - } - if (irparams.rawlen < 2 * NEC_BITS + 4) { - return ERR; - } - // Initial space - if (!MATCH_SPACE(results->rawbuf[offset], NEC_HDR_SPACE)) { - return ERR; - } - offset++; - for (int i = 0; i < NEC_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) { - return ERR; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE)) { - data = (data << 1) | 1; - } - else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) { - data <<= 1; - } - else { - return ERR; - } - offset++; - } - // Success - results->bits = NEC_BITS; - results->value = data; - results->decode_type = NEC; - return DECODED; -} - -long IRrecv::decodeSony(decode_results *results) { - long data = 0; - if (irparams.rawlen < 2 * SONY_BITS + 2) { - return ERR; - } - int offset = 0; // Dont skip first space, check its size - - // Some Sony's deliver repeats fast after first - // unfortunately can't spot difference from of repeat from two fast clicks - if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) { - // Serial.print("IR Gap found: "); - results->bits = 0; - results->value = REPEAT; - results->decode_type = SANYO; - return DECODED; - } - offset++; - - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) { - return ERR; - } - offset++; - - while (offset + 1 < irparams.rawlen) { - if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) { - break; - } - offset++; - if (MATCH_MARK(results->rawbuf[offset], SONY_ONE_MARK)) { - data = (data << 1) | 1; - } - else if (MATCH_MARK(results->rawbuf[offset], SONY_ZERO_MARK)) { - data <<= 1; - } - else { - return ERR; - } - offset++; - } - - // Success - results->bits = (offset - 1) / 2; - if (results->bits < 12) { - results->bits = 0; - return ERR; - } - results->value = data; - results->decode_type = SONY; - return DECODED; -} - -// I think this is a Sanyo decoder - serial = SA 8650B -// Looks like Sony except for timings, 48 chars of data and time/space different -long IRrecv::decodeSanyo(decode_results *results) { - long data = 0; - if (irparams.rawlen < 2 * SANYO_BITS + 2) { - return ERR; - } - int offset = 0; // Skip first space - // Initial space - /* Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay - Serial.print("IR Gap: "); - Serial.println( results->rawbuf[offset]); - Serial.println( "test against:"); - Serial.println(results->rawbuf[offset]); - */ - if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) { - // Serial.print("IR Gap found: "); - results->bits = 0; - results->value = REPEAT; - results->decode_type = SANYO; - return DECODED; - } - offset++; - - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) { - return ERR; - } - offset++; - - // Skip Second Mark - if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) { - return ERR; - } - offset++; - - while (offset + 1 < irparams.rawlen) { - if (!MATCH_SPACE(results->rawbuf[offset], SANYO_HDR_SPACE)) { - break; - } - offset++; - if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) { - data = (data << 1) | 1; - } - else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) { - data <<= 1; - } - else { - return ERR; - } - offset++; - } - - // Success - results->bits = (offset - 1) / 2; - if (results->bits < 12) { - results->bits = 0; - return ERR; - } - results->value = data; - results->decode_type = SANYO; - return DECODED; -} - -// Looks like Sony except for timings, 48 chars of data and time/space different -long IRrecv::decodeMitsubishi(decode_results *results) { - // Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2); - long data = 0; - if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) { - return ERR; - } - int offset = 0; // Skip first space - // Initial space - /* Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay - Serial.print("IR Gap: "); - Serial.println( results->rawbuf[offset]); - Serial.println( "test against:"); - Serial.println(results->rawbuf[offset]); - */ - /* Not seeing double keys from Mitsubishi - if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) { - // Serial.print("IR Gap found: "); - results->bits = 0; - results->value = REPEAT; - results->decode_type = MITSUBISHI; - return DECODED; - } - */ - offset++; - - // Typical - // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7 - - // Initial Space - if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) { - return ERR; - } - offset++; - while (offset + 1 < irparams.rawlen) { - if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) { - data = (data << 1) | 1; - } - else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) { - data <<= 1; - } - else { - // Serial.println("A"); Serial.println(offset); Serial.println(results->rawbuf[offset]); - return ERR; - } - offset++; - if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) { - // Serial.println("B"); Serial.println(offset); Serial.println(results->rawbuf[offset]); - break; - } - offset++; - } - - // Success - results->bits = (offset - 1) / 2; - if (results->bits < MITSUBISHI_BITS) { - results->bits = 0; - return ERR; - } - results->value = data; - results->decode_type = MITSUBISHI; - return DECODED; -} - - -// Gets one undecoded level at a time from the raw buffer. -// The RC5/6 decoding is easier if the data is broken into time intervals. -// E.g. if the buffer has MARK for 2 time intervals and SPACE for 1, -// successive calls to getRClevel will return MARK, MARK, SPACE. -// offset and used are updated to keep track of the current position. -// t1 is the time interval for a single bit in microseconds. -// Returns -1 for error (measured time interval is not a multiple of t1). -int IRrecv::getRClevel(decode_results *results, int *offset, int *used, int t1) { - if (*offset >= results->rawlen) { - // After end of recorded buffer, assume SPACE. - return SPACE; - } - int width = results->rawbuf[*offset]; - int val = ((*offset) % 2) ? MARK : SPACE; - int correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS; - - int avail; - if (MATCH(width, t1 + correction)) { - avail = 1; - } - else if (MATCH(width, 2*t1 + correction)) { - avail = 2; - } - else if (MATCH(width, 3*t1 + correction)) { - avail = 3; - } - else { - return -1; - } - - (*used)++; - if (*used >= avail) { - *used = 0; - (*offset)++; - } -#ifdef DEBUG - if (val == MARK) { - Serial.println("MARK"); - } - else { - Serial.println("SPACE"); - } -#endif - return val; -} - -long IRrecv::decodeRC5(decode_results *results) { - if (irparams.rawlen < MIN_RC5_SAMPLES + 2) { - return ERR; - } - int offset = 1; // Skip gap space - long data = 0; - int used = 0; - // Get start bits - if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return ERR; - if (getRClevel(results, &offset, &used, RC5_T1) != SPACE) return ERR; - if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return ERR; - int nbits; - for (nbits = 0; offset < irparams.rawlen; nbits++) { - int levelA = getRClevel(results, &offset, &used, RC5_T1); - int levelB = getRClevel(results, &offset, &used, RC5_T1); - if (levelA == SPACE && levelB == MARK) { - // 1 bit - data = (data << 1) | 1; - } - else if (levelA == MARK && levelB == SPACE) { - // zero bit - data <<= 1; - } - else { - return ERR; - } - } - - // Success - results->bits = nbits; - results->value = data; - results->decode_type = RC5; - return DECODED; -} - -long IRrecv::decodeRC6(decode_results *results) { - if (results->rawlen < MIN_RC6_SAMPLES) { - return ERR; - } - int offset = 1; // Skip first space - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], RC6_HDR_MARK)) { - return ERR; - } - offset++; - if (!MATCH_SPACE(results->rawbuf[offset], RC6_HDR_SPACE)) { - return ERR; - } - offset++; - long data = 0; - int used = 0; - // Get start bit (1) - if (getRClevel(results, &offset, &used, RC6_T1) != MARK) return ERR; - if (getRClevel(results, &offset, &used, RC6_T1) != SPACE) return ERR; - int nbits; - for (nbits = 0; offset < results->rawlen; nbits++) { - int levelA, levelB; // Next two levels - levelA = getRClevel(results, &offset, &used, RC6_T1); - if (nbits == 3) { - // T bit is double wide; make sure second half matches - if (levelA != getRClevel(results, &offset, &used, RC6_T1)) return ERR; - } - levelB = getRClevel(results, &offset, &used, RC6_T1); - if (nbits == 3) { - // T bit is double wide; make sure second half matches - if (levelB != getRClevel(results, &offset, &used, RC6_T1)) return ERR; - } - if (levelA == MARK && levelB == SPACE) { // reversed compared to RC5 - // 1 bit - data = (data << 1) | 1; - } - else if (levelA == SPACE && levelB == MARK) { - // zero bit - data <<= 1; - } - else { - return ERR; // Error - } - } - // Success - results->bits = nbits; - results->value = data; - results->decode_type = RC6; - return DECODED; -} -long IRrecv::decodePanasonic(decode_results *results) { - unsigned long long data = 0; - int offset = 1; - - if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) { - return ERR; - } - offset++; - if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) { - return ERR; - } - offset++; - - // decode address - for (int i = 0; i < PANASONIC_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_BIT_MARK)) { - return ERR; - } - if (MATCH_SPACE(results->rawbuf[offset],PANASONIC_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset],PANASONIC_ZERO_SPACE)) { - data <<= 1; - } else { - return ERR; - } - offset++; - } - results->value = (unsigned long)data; - results->panasonicAddress = (unsigned int)(data >> 32); - results->decode_type = PANASONIC; - results->bits = PANASONIC_BITS; - return DECODED; -} - -long IRrecv::decodeLG(decode_results *results) { - long data = 0; - int offset = 1; // Skip first space - - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], LG_HDR_MARK)) { - return ERR; - } - offset++; - if (irparams.rawlen < 2 * LG_BITS + 1 ) { - return ERR; - } - // Initial space - if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) { - return ERR; - } - offset++; - for (int i = 0; i < LG_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) { - return ERR; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) { - data = (data << 1) | 1; - } - else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) { - data <<= 1; - } - else { - return ERR; - } - offset++; - } - //Stop bit - if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)){ - return ERR; - } - // Success - results->bits = LG_BITS; - results->value = data; - results->decode_type = LG; - return DECODED; -} - - -long IRrecv::decodeJVC(decode_results *results) { - long data = 0; - int offset = 1; // Skip first space - // Check for repeat - if (irparams.rawlen - 1 == 33 && - MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK) && - MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)) { - results->bits = 0; - results->value = REPEAT; - results->decode_type = JVC; - return DECODED; - } - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], JVC_HDR_MARK)) { - return ERR; - } - offset++; - if (irparams.rawlen < 2 * JVC_BITS + 1 ) { - return ERR; - } - // Initial space - if (!MATCH_SPACE(results->rawbuf[offset], JVC_HDR_SPACE)) { - return ERR; - } - offset++; - for (int i = 0; i < JVC_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) { - return ERR; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) { - data = (data << 1) | 1; - } - else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) { - data <<= 1; - } - else { - return ERR; - } - offset++; - } - //Stop bit - if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)){ - return ERR; - } - // Success - results->bits = JVC_BITS; - results->value = data; - results->decode_type = JVC; - return DECODED; -} - -// SAMSUNGs have a repeat only 4 items long -long IRrecv::decodeSAMSUNG(decode_results *results) { - long data = 0; - int offset = 1; // Skip first space - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) { - return ERR; - } - offset++; - // Check for repeat - if (irparams.rawlen == 4 && - MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE) && - MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)) { - results->bits = 0; - results->value = REPEAT; - results->decode_type = SAMSUNG; - return DECODED; - } - if (irparams.rawlen < 2 * SAMSUNG_BITS + 4) { - return ERR; - } - // Initial space - if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) { - return ERR; - } - offset++; - for (int i = 0; i < SAMSUNG_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) { - return ERR; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) { - data = (data << 1) | 1; - } - else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) { - data <<= 1; - } - else { - return ERR; - } - offset++; - } - // Success - results->bits = SAMSUNG_BITS; - results->value = data; - results->decode_type = SAMSUNG; - return DECODED; -} - -/* ----------------------------------------------------------------------- - * hashdecode - decode an arbitrary IR code. - * Instead of decoding using a standard encoding scheme - * (e.g. Sony, NEC, RC5), the code is hashed to a 32-bit value. - * - * The algorithm: look at the sequence of MARK signals, and see if each one - * is shorter (0), the same length (1), or longer (2) than the previous. - * Do the same with the SPACE signals. Hszh the resulting sequence of 0's, - * 1's, and 2's to a 32-bit value. This will give a unique value for each - * different code (probably), for most code systems. - * - * http://arcfn.com/2010/01/using-arbitrary-remotes-with-arduino.html - */ - -// Compare two tick values, returning 0 if newval is shorter, -// 1 if newval is equal, and 2 if newval is longer -// Use a tolerance of 20% -int IRrecv::compare(unsigned int oldval, unsigned int newval) { - if (newval < oldval * .8) { - return 0; - } - else if (oldval < newval * .8) { - return 2; - } - else { - return 1; - } -} - -// Use FNV hash algorithm: http://isthe.com/chongo/tech/comp/fnv/#FNV-param -#define FNV_PRIME_32 16777619 -#define FNV_BASIS_32 2166136261 - -/* Converts the raw code values into a 32-bit hash code. - * Hopefully this code is unique for each button. - * This isn't a "real" decoding, just an arbitrary value. - */ -long IRrecv::decodeHash(decode_results *results) { - // Require at least 6 samples to prevent triggering on noise - if (results->rawlen < 6) { - return ERR; - } - long hash = FNV_BASIS_32; - for (int i = 1; i+2 < results->rawlen; i++) { - int value = compare(results->rawbuf[i], results->rawbuf[i+2]); - // Add value into the hash - hash = (hash * FNV_PRIME_32) ^ value; - } - results->value = hash; - results->bits = 32; - results->decode_type = UNKNOWN; - return DECODED; -} - -/* Sharp and DISH support by Todd Treece ( http://unionbridge.org/design/ircommand ) - -The Dish send function needs to be repeated 4 times, and the Sharp function -has the necessary repeat built in because of the need to invert the signal. - -Sharp protocol documentation: -http://www.sbprojects.com/knowledge/ir/sharp.htm - -Here are the LIRC files that I found that seem to match the remote codes -from the oscilloscope: - -Sharp LCD TV: -http://lirc.sourceforge.net/remotes/sharp/GA538WJSA - -DISH NETWORK (echostar 301): -http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx - -For the DISH codes, only send the last for characters of the hex. -i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the -linked LIRC file. -*/ - -void IRsend::sendSharpRaw(unsigned long data, int nbits) { - enableIROut(38); - - // Sending codes in bursts of 3 (normal, inverted, normal) makes transmission - // much more reliable. That's the exact behaviour of CD-S6470 remote control. - for (int n = 0; n < 3; n++) { - for (int i = 1 << (nbits-1); i > 0; i>>=1) { - if (data & i) { - mark(SHARP_BIT_MARK); - space(SHARP_ONE_SPACE); - } - else { - mark(SHARP_BIT_MARK); - space(SHARP_ZERO_SPACE); - } - } - - mark(SHARP_BIT_MARK); - space(SHARP_ZERO_SPACE); - delay(40); - - data = data ^ SHARP_TOGGLE_MASK; - } -} - -// Sharp send compatible with data obtained through decodeSharp -void IRsend::sendSharp(unsigned int address, unsigned int command) { - sendSharpRaw((address << 10) | (command << 2) | 2, 15); -} - -void IRsend::sendDISH(unsigned long data, int nbits) { - enableIROut(56); - mark(DISH_HDR_MARK); - space(DISH_HDR_SPACE); - for (int i = 0; i < nbits; i++) { - if (data & DISH_TOP_BIT) { - mark(DISH_BIT_MARK); - space(DISH_ONE_SPACE); - } - else { - mark(DISH_BIT_MARK); - space(DISH_ZERO_SPACE); - } - data <<= 1; - } -}
--- a/service/busyboxArduino/IRremote/IRremote.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -/* - * IRremote - * Version 0.1 July, 2009 - * Copyright 2009 Ken Shirriff - * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.htm http://arcfn.com - * Edited by Mitra to add new controller SANYO - * - * Interrupt code based on NECIRrcv by Joe Knapp - * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 - * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ - * - * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) -* LG added by Darryl Smith (based on the JVC protocol) - */ - -#ifndef IRremote_h -#define IRremote_h - -// The following are compile-time library options. -// If you change them, recompile the library. -// If DEBUG is defined, a lot of debugging output will be printed during decoding. -// TEST must be defined for the IRtest unittests to work. It will make some -// methods virtual, which will be slightly slower, which is why it is optional. -// #define DEBUG -// #define TEST - -// Results returned from the decoder -class decode_results { -public: - int decode_type; // NEC, SONY, RC5, UNKNOWN - union { // This is used for decoding Panasonic and Sharp data - unsigned int panasonicAddress; - unsigned int sharpAddress; - }; - unsigned long value; // Decoded value - int bits; // Number of bits in decoded value - volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks - int rawlen; // Number of records in rawbuf. -}; - -// Values for decode_type -#define NEC 1 -#define SONY 2 -#define RC5 3 -#define RC6 4 -#define DISH 5 -#define SHARP 6 -#define PANASONIC 7 -#define JVC 8 -#define SANYO 9 -#define MITSUBISHI 10 -#define SAMSUNG 11 -#define LG 12 -#define UNKNOWN -1 - -// Decoded value for NEC when a repeat code is received -#define REPEAT 0xffffffff - -// main class for receiving IR -class IRrecv -{ -public: - IRrecv(int recvpin); - void blink13(int blinkflag); - int decode(decode_results *results); - void enableIRIn(); - void resume(); -private: - // These are called by decode - int getRClevel(decode_results *results, int *offset, int *used, int t1); - long decodeNEC(decode_results *results); - long decodeSony(decode_results *results); - long decodeSanyo(decode_results *results); - long decodeMitsubishi(decode_results *results); - long decodeRC5(decode_results *results); - long decodeRC6(decode_results *results); - long decodePanasonic(decode_results *results); - long decodeLG(decode_results *results); - long decodeJVC(decode_results *results); - long decodeSAMSUNG(decode_results *results); - long decodeHash(decode_results *results); - int compare(unsigned int oldval, unsigned int newval); - -} -; - -// Only used for testing; can remove virtual for shorter code -#ifdef TEST -#define VIRTUAL virtual -#else -#define VIRTUAL -#endif - -class IRsend -{ -public: - IRsend() {} - void sendNEC(unsigned long data, int nbits); - void sendSony(unsigned long data, int nbits); - // Neither Sanyo nor Mitsubishi send is implemented yet - // void sendSanyo(unsigned long data, int nbits); - // void sendMitsubishi(unsigned long data, int nbits); - void sendRaw(unsigned int buf[], int len, int hz); - void sendRC5(unsigned long data, int nbits); - void sendRC6(unsigned long data, int nbits); - void sendDISH(unsigned long data, int nbits); - void sendSharp(unsigned int address, unsigned int command); - void sendSharpRaw(unsigned long data, int nbits); - void sendPanasonic(unsigned int address, unsigned long data); - void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does. - // private: - void sendSAMSUNG(unsigned long data, int nbits); - void enableIROut(int khz); - VIRTUAL void mark(int usec); - VIRTUAL void space(int usec); -} -; - -// Some useful constants - -#define USECPERTICK 50 // microseconds per clock interrupt tick -#define RAWBUF 100 // Length of raw duration buffer - -// Marks tend to be 100us too long, and spaces 100us too short -// when received due to sensor lag. -#define MARK_EXCESS 100 - -#endif
--- a/service/busyboxArduino/IRremote/IRremoteInt.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,515 +0,0 @@ -/* - * IRremote - * Version 0.1 July, 2009 - * Copyright 2009 Ken Shirriff - * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html - * - * Modified by Paul Stoffregen <paul@pjrc.com> to support other boards and timers - * - * Interrupt code based on NECIRrcv by Joe Knapp - * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 - * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ - * - * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) - */ - -#ifndef IRremoteint_h -#define IRremoteint_h - -#if defined(ARDUINO) && ARDUINO >= 100 -#include <Arduino.h> -#else -#include <WProgram.h> -#endif - -// define which timer to use -// -// Uncomment the timer you wish to use on your board. If you -// are using another library which uses timer2, you have options -// to switch IRremote to use a different timer. - -// Arduino Mega -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) - //#define IR_USE_TIMER1 // tx = pin 11 - #define IR_USE_TIMER2 // tx = pin 9 - //#define IR_USE_TIMER3 // tx = pin 5 - //#define IR_USE_TIMER4 // tx = pin 6 - //#define IR_USE_TIMER5 // tx = pin 46 - -// Teensy 1.0 -#elif defined(__AVR_AT90USB162__) - #define IR_USE_TIMER1 // tx = pin 17 - -// Teensy 2.0 -#elif defined(__AVR_ATmega32U4__) - //#define IR_USE_TIMER1 // tx = pin 14 - //#define IR_USE_TIMER3 // tx = pin 9 - #define IR_USE_TIMER4_HS // tx = pin 10 - -// Teensy 3.0 -#elif defined(__MK20DX128__) - #define IR_USE_TIMER_CMT // tx = pin 5 - -// Teensy++ 1.0 & 2.0 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) - //#define IR_USE_TIMER1 // tx = pin 25 - #define IR_USE_TIMER2 // tx = pin 1 - //#define IR_USE_TIMER3 // tx = pin 16 - -// Sanguino -#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) - //#define IR_USE_TIMER1 // tx = pin 13 - #define IR_USE_TIMER2 // tx = pin 14 - -// Atmega8 -#elif defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__) - #define IR_USE_TIMER1 // tx = pin 9 - -// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc -#else - //#define IR_USE_TIMER1 // tx = pin 9 - #define IR_USE_TIMER2 // tx = pin 3 -#endif - - - -#ifdef F_CPU -#define SYSCLOCK F_CPU // main Arduino clock -#else -#define SYSCLOCK 16000000 // main Arduino clock -#endif - -#define ERR 0 -#define DECODED 1 - - -// defines for setting and clearing register bits -#ifndef cbi -#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) -#endif -#ifndef sbi -#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) -#endif - -// Pulse parms are *50-100 for the Mark and *50+100 for the space -// First MARK is the one after the long gap -// pulse parameters in usec -#define NEC_HDR_MARK 9000 -#define NEC_HDR_SPACE 4500 -#define NEC_BIT_MARK 560 -#define NEC_ONE_SPACE 1600 -#define NEC_ZERO_SPACE 560 -#define NEC_RPT_SPACE 2250 - -#define SONY_HDR_MARK 2400 -#define SONY_HDR_SPACE 600 -#define SONY_ONE_MARK 1200 -#define SONY_ZERO_MARK 600 -#define SONY_RPT_LENGTH 45000 -#define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround - -// SA 8650B -#define SANYO_HDR_MARK 3500 // seen range 3500 -#define SANYO_HDR_SPACE 950 // seen 950 -#define SANYO_ONE_MARK 2400 // seen 2400 -#define SANYO_ZERO_MARK 700 // seen 700 -#define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround -#define SANYO_RPT_LENGTH 45000 - -// Mitsubishi RM 75501 -// 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7 - -// #define MITSUBISHI_HDR_MARK 250 // seen range 3500 -#define MITSUBISHI_HDR_SPACE 350 // 7*50+100 -#define MITSUBISHI_ONE_MARK 1950 // 41*50-100 -#define MITSUBISHI_ZERO_MARK 750 // 17*50-100 -// #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround -// #define MITSUBISHI_RPT_LENGTH 45000 - - -#define RC5_T1 889 -#define RC5_RPT_LENGTH 46000 - -#define RC6_HDR_MARK 2666 -#define RC6_HDR_SPACE 889 -#define RC6_T1 444 -#define RC6_RPT_LENGTH 46000 - -#define SHARP_BIT_MARK 245 -#define SHARP_ONE_SPACE 1805 -#define SHARP_ZERO_SPACE 795 -#define SHARP_GAP 600000 -#define SHARP_TOGGLE_MASK 0x3FF -#define SHARP_RPT_SPACE 3000 - -#define DISH_HDR_MARK 400 -#define DISH_HDR_SPACE 6100 -#define DISH_BIT_MARK 400 -#define DISH_ONE_SPACE 1700 -#define DISH_ZERO_SPACE 2800 -#define DISH_RPT_SPACE 6200 -#define DISH_TOP_BIT 0x8000 - -#define PANASONIC_HDR_MARK 3502 -#define PANASONIC_HDR_SPACE 1750 -#define PANASONIC_BIT_MARK 502 -#define PANASONIC_ONE_SPACE 1244 -#define PANASONIC_ZERO_SPACE 400 - -#define JVC_HDR_MARK 8000 -#define JVC_HDR_SPACE 4000 -#define JVC_BIT_MARK 600 -#define JVC_ONE_SPACE 1600 -#define JVC_ZERO_SPACE 550 -#define JVC_RPT_LENGTH 60000 - -#define LG_HDR_MARK 8000 -#define LG_HDR_SPACE 4000 -#define LG_BIT_MARK 600 -#define LG_ONE_SPACE 1600 -#define LG_ZERO_SPACE 550 -#define LG_RPT_LENGTH 60000 - -#define SAMSUNG_HDR_MARK 5000 -#define SAMSUNG_HDR_SPACE 5000 -#define SAMSUNG_BIT_MARK 560 -#define SAMSUNG_ONE_SPACE 1600 -#define SAMSUNG_ZERO_SPACE 560 -#define SAMSUNG_RPT_SPACE 2250 - - -#define SHARP_BITS 15 -#define DISH_BITS 16 - -#define TOLERANCE 25 // percent tolerance in measurements -#define LTOL (1.0 - TOLERANCE/100.) -#define UTOL (1.0 + TOLERANCE/100.) - -#define _GAP 5000 // Minimum map between transmissions -#define GAP_TICKS (_GAP/USECPERTICK) - -#define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK)) -#define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1)) - -// receiver states -#define STATE_IDLE 2 -#define STATE_MARK 3 -#define STATE_SPACE 4 -#define STATE_STOP 5 - -// information for the interrupt handler -typedef struct { - uint8_t recvpin; // pin for IR data from detector - uint8_t rcvstate; // state machine - uint8_t blinkflag; // TRUE to enable blinking of pin 13 on IR processing - unsigned int timer; // state timer, counts 50uS ticks. - unsigned int rawbuf[RAWBUF]; // raw data - uint8_t rawlen; // counter of entries in rawbuf -} -irparams_t; - -// Defined in IRremote.cpp -extern volatile irparams_t irparams; - -// IR detector output is active low -#define MARK 0 -#define SPACE 1 - -#define TOPBIT 0x80000000 - -#define NEC_BITS 32 -#define SONY_BITS 12 -#define SANYO_BITS 12 -#define MITSUBISHI_BITS 16 -#define MIN_RC5_SAMPLES 11 -#define MIN_RC6_SAMPLES 1 -#define PANASONIC_BITS 48 -#define JVC_BITS 16 -#define LG_BITS 28 -#define SAMSUNG_BITS 32 - - - - -// defines for timer2 (8 bits) -#if defined(IR_USE_TIMER2) -#define TIMER_RESET -#define TIMER_ENABLE_PWM (TCCR2A |= _BV(COM2B1)) -#define TIMER_DISABLE_PWM (TCCR2A &= ~(_BV(COM2B1))) -#define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A)) -#define TIMER_DISABLE_INTR (TIMSK2 = 0) -#define TIMER_INTR_NAME TIMER2_COMPA_vect -#define TIMER_CONFIG_KHZ(val) ({ \ - const uint8_t pwmval = SYSCLOCK / 2000 / (val); \ - TCCR2A = _BV(WGM20); \ - TCCR2B = _BV(WGM22) | _BV(CS20); \ - OCR2A = pwmval; \ - OCR2B = pwmval / 3; \ -}) -#define TIMER_COUNT_TOP (SYSCLOCK * USECPERTICK / 1000000) -#if (TIMER_COUNT_TOP < 256) -#define TIMER_CONFIG_NORMAL() ({ \ - TCCR2A = _BV(WGM21); \ - TCCR2B = _BV(CS20); \ - OCR2A = TIMER_COUNT_TOP; \ - TCNT2 = 0; \ -}) -#else -#define TIMER_CONFIG_NORMAL() ({ \ - TCCR2A = _BV(WGM21); \ - TCCR2B = _BV(CS21); \ - OCR2A = TIMER_COUNT_TOP / 8; \ - TCNT2 = 0; \ -}) -#endif -#if defined(CORE_OC2B_PIN) -#define TIMER_PWM_PIN CORE_OC2B_PIN /* Teensy */ -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define TIMER_PWM_PIN 9 /* Arduino Mega */ -#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) -#define TIMER_PWM_PIN 14 /* Sanguino */ -#else -#define TIMER_PWM_PIN 3 /* Arduino Duemilanove, Diecimila, LilyPad, etc */ -#endif - - -// defines for timer1 (16 bits) -#elif defined(IR_USE_TIMER1) -#define TIMER_RESET -#define TIMER_ENABLE_PWM (TCCR1A |= _BV(COM1A1)) -#define TIMER_DISABLE_PWM (TCCR1A &= ~(_BV(COM1A1))) -#if defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__) - #define TIMER_ENABLE_INTR (TIMSK = _BV(OCIE1A)) - #define TIMER_DISABLE_INTR (TIMSK = 0) -#else - #define TIMER_ENABLE_INTR (TIMSK1 = _BV(OCIE1A)) - #define TIMER_DISABLE_INTR (TIMSK1 = 0) -#endif -#define TIMER_INTR_NAME TIMER1_COMPA_vect -#define TIMER_CONFIG_KHZ(val) ({ \ - const uint16_t pwmval = SYSCLOCK / 2000 / (val); \ - TCCR1A = _BV(WGM11); \ - TCCR1B = _BV(WGM13) | _BV(CS10); \ - ICR1 = pwmval; \ - OCR1A = pwmval / 3; \ -}) -#define TIMER_CONFIG_NORMAL() ({ \ - TCCR1A = 0; \ - TCCR1B = _BV(WGM12) | _BV(CS10); \ - OCR1A = SYSCLOCK * USECPERTICK / 1000000; \ - TCNT1 = 0; \ -}) -#if defined(CORE_OC1A_PIN) -#define TIMER_PWM_PIN CORE_OC1A_PIN /* Teensy */ -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define TIMER_PWM_PIN 11 /* Arduino Mega */ -#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) -#define TIMER_PWM_PIN 13 /* Sanguino */ -#else -#define TIMER_PWM_PIN 9 /* Arduino Duemilanove, Diecimila, LilyPad, etc */ -#endif - - -// defines for timer3 (16 bits) -#elif defined(IR_USE_TIMER3) -#define TIMER_RESET -#define TIMER_ENABLE_PWM (TCCR3A |= _BV(COM3A1)) -#define TIMER_DISABLE_PWM (TCCR3A &= ~(_BV(COM3A1))) -#define TIMER_ENABLE_INTR (TIMSK3 = _BV(OCIE3A)) -#define TIMER_DISABLE_INTR (TIMSK3 = 0) -#define TIMER_INTR_NAME TIMER3_COMPA_vect -#define TIMER_CONFIG_KHZ(val) ({ \ - const uint16_t pwmval = SYSCLOCK / 2000 / (val); \ - TCCR3A = _BV(WGM31); \ - TCCR3B = _BV(WGM33) | _BV(CS30); \ - ICR3 = pwmval; \ - OCR3A = pwmval / 3; \ -}) -#define TIMER_CONFIG_NORMAL() ({ \ - TCCR3A = 0; \ - TCCR3B = _BV(WGM32) | _BV(CS30); \ - OCR3A = SYSCLOCK * USECPERTICK / 1000000; \ - TCNT3 = 0; \ -}) -#if defined(CORE_OC3A_PIN) -#define TIMER_PWM_PIN CORE_OC3A_PIN /* Teensy */ -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define TIMER_PWM_PIN 5 /* Arduino Mega */ -#else -#error "Please add OC3A pin number here\n" -#endif - - -// defines for timer4 (10 bits, high speed option) -#elif defined(IR_USE_TIMER4_HS) -#define TIMER_RESET -#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1)) -#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1))) -#define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4)) -#define TIMER_DISABLE_INTR (TIMSK4 = 0) -#define TIMER_INTR_NAME TIMER4_OVF_vect -#define TIMER_CONFIG_KHZ(val) ({ \ - const uint16_t pwmval = SYSCLOCK / 2000 / (val); \ - TCCR4A = (1<<PWM4A); \ - TCCR4B = _BV(CS40); \ - TCCR4C = 0; \ - TCCR4D = (1<<WGM40); \ - TCCR4E = 0; \ - TC4H = pwmval >> 8; \ - OCR4C = pwmval; \ - TC4H = (pwmval / 3) >> 8; \ - OCR4A = (pwmval / 3) & 255; \ -}) -#define TIMER_CONFIG_NORMAL() ({ \ - TCCR4A = 0; \ - TCCR4B = _BV(CS40); \ - TCCR4C = 0; \ - TCCR4D = 0; \ - TCCR4E = 0; \ - TC4H = (SYSCLOCK * USECPERTICK / 1000000) >> 8; \ - OCR4C = (SYSCLOCK * USECPERTICK / 1000000) & 255; \ - TC4H = 0; \ - TCNT4 = 0; \ -}) -#if defined(CORE_OC4A_PIN) -#define TIMER_PWM_PIN CORE_OC4A_PIN /* Teensy */ -#elif defined(__AVR_ATmega32U4__) -#define TIMER_PWM_PIN 13 /* Leonardo */ -#else -#error "Please add OC4A pin number here\n" -#endif - - -// defines for timer4 (16 bits) -#elif defined(IR_USE_TIMER4) -#define TIMER_RESET -#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1)) -#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1))) -#define TIMER_ENABLE_INTR (TIMSK4 = _BV(OCIE4A)) -#define TIMER_DISABLE_INTR (TIMSK4 = 0) -#define TIMER_INTR_NAME TIMER4_COMPA_vect -#define TIMER_CONFIG_KHZ(val) ({ \ - const uint16_t pwmval = SYSCLOCK / 2000 / (val); \ - TCCR4A = _BV(WGM41); \ - TCCR4B = _BV(WGM43) | _BV(CS40); \ - ICR4 = pwmval; \ - OCR4A = pwmval / 3; \ -}) -#define TIMER_CONFIG_NORMAL() ({ \ - TCCR4A = 0; \ - TCCR4B = _BV(WGM42) | _BV(CS40); \ - OCR4A = SYSCLOCK * USECPERTICK / 1000000; \ - TCNT4 = 0; \ -}) -#if defined(CORE_OC4A_PIN) -#define TIMER_PWM_PIN CORE_OC4A_PIN -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define TIMER_PWM_PIN 6 /* Arduino Mega */ -#else -#error "Please add OC4A pin number here\n" -#endif - - -// defines for timer5 (16 bits) -#elif defined(IR_USE_TIMER5) -#define TIMER_RESET -#define TIMER_ENABLE_PWM (TCCR5A |= _BV(COM5A1)) -#define TIMER_DISABLE_PWM (TCCR5A &= ~(_BV(COM5A1))) -#define TIMER_ENABLE_INTR (TIMSK5 = _BV(OCIE5A)) -#define TIMER_DISABLE_INTR (TIMSK5 = 0) -#define TIMER_INTR_NAME TIMER5_COMPA_vect -#define TIMER_CONFIG_KHZ(val) ({ \ - const uint16_t pwmval = SYSCLOCK / 2000 / (val); \ - TCCR5A = _BV(WGM51); \ - TCCR5B = _BV(WGM53) | _BV(CS50); \ - ICR5 = pwmval; \ - OCR5A = pwmval / 3; \ -}) -#define TIMER_CONFIG_NORMAL() ({ \ - TCCR5A = 0; \ - TCCR5B = _BV(WGM52) | _BV(CS50); \ - OCR5A = SYSCLOCK * USECPERTICK / 1000000; \ - TCNT5 = 0; \ -}) -#if defined(CORE_OC5A_PIN) -#define TIMER_PWM_PIN CORE_OC5A_PIN -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define TIMER_PWM_PIN 46 /* Arduino Mega */ -#else -#error "Please add OC5A pin number here\n" -#endif - - -// defines for special carrier modulator timer -#elif defined(IR_USE_TIMER_CMT) -#define TIMER_RESET ({ \ - uint8_t tmp = CMT_MSC; \ - CMT_CMD2 = 30; \ -}) -#define TIMER_ENABLE_PWM CORE_PIN5_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_DSE|PORT_PCR_SRE -#define TIMER_DISABLE_PWM CORE_PIN5_CONFIG = PORT_PCR_MUX(1)|PORT_PCR_DSE|PORT_PCR_SRE -#define TIMER_ENABLE_INTR NVIC_ENABLE_IRQ(IRQ_CMT) -#define TIMER_DISABLE_INTR NVIC_DISABLE_IRQ(IRQ_CMT) -#define TIMER_INTR_NAME cmt_isr -#ifdef ISR -#undef ISR -#endif -#define ISR(f) void f(void) -#if F_BUS == 48000000 -#define CMT_PPS_VAL 5 -#else -#define CMT_PPS_VAL 2 -#endif -#define TIMER_CONFIG_KHZ(val) ({ \ - SIM_SCGC4 |= SIM_SCGC4_CMT; \ - SIM_SOPT2 |= SIM_SOPT2_PTD7PAD; \ - CMT_PPS = CMT_PPS_VAL; \ - CMT_CGH1 = 2667 / val; \ - CMT_CGL1 = 5333 / val; \ - CMT_CMD1 = 0; \ - CMT_CMD2 = 30; \ - CMT_CMD3 = 0; \ - CMT_CMD4 = 0; \ - CMT_OC = 0x60; \ - CMT_MSC = 0x01; \ -}) -#define TIMER_CONFIG_NORMAL() ({ \ - SIM_SCGC4 |= SIM_SCGC4_CMT; \ - CMT_PPS = CMT_PPS_VAL; \ - CMT_CGH1 = 1; \ - CMT_CGL1 = 1; \ - CMT_CMD1 = 0; \ - CMT_CMD2 = 30; \ - CMT_CMD3 = 0; \ - CMT_CMD4 = 19; \ - CMT_OC = 0; \ - CMT_MSC = 0x03; \ -}) -#define TIMER_PWM_PIN 5 - - -#else // unknown timer -#error "Internal code configuration error, no known IR_USE_TIMER# defined\n" -#endif - - -// defines for blinking the LED -#if defined(CORE_LED0_PIN) -#define BLINKLED CORE_LED0_PIN -#define BLINKLED_ON() (digitalWrite(CORE_LED0_PIN, HIGH)) -#define BLINKLED_OFF() (digitalWrite(CORE_LED0_PIN, LOW)) -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define BLINKLED 13 -#define BLINKLED_ON() (PORTB |= B10000000) -#define BLINKLED_OFF() (PORTB &= B01111111) -#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) -#define BLINKLED 0 -#define BLINKLED_ON() (PORTD |= B00000001) -#define BLINKLED_OFF() (PORTD &= B11111110) -#else -#define BLINKLED 13 -#define BLINKLED_ON() (PORTB |= B00100000) -#define BLINKLED_OFF() (PORTB &= B11011111) -#endif - -#endif
--- a/service/busyboxArduino/IRremote/LICENSE.txt Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,458 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. -
--- a/service/busyboxArduino/IRremote/examples/IRrecord/IRrecord.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * IRrecord: record and play back IR signals as a minimal - * An IR detector/demodulator must be connected to the input RECV_PIN. - * An IR LED must be connected to the output PWM pin 3. - * A button must be connected to the input BUTTON_PIN; this is the - * send button. - * A visible LED can be connected to STATUS_PIN to provide status. - * - * The logic is: - * If the button is pressed, send the IR code. - * If an IR code is received, record it. - * - * Version 0.11 September, 2009 - * Copyright 2009 Ken Shirriff - * http://arcfn.com - */ - -#include <IRremote.h> - -int RECV_PIN = 11; -int BUTTON_PIN = 12; -int STATUS_PIN = 13; - -IRrecv irrecv(RECV_PIN); -IRsend irsend; - -decode_results results; - -void setup() -{ - Serial.begin(9600); - irrecv.enableIRIn(); // Start the receiver - pinMode(BUTTON_PIN, INPUT); - pinMode(STATUS_PIN, OUTPUT); -} - -// Storage for the recorded code -int codeType = -1; // The type of code -unsigned long codeValue; // The code value if not raw -unsigned int rawCodes[RAWBUF]; // The durations if raw -int codeLen; // The length of the code -int toggle = 0; // The RC5/6 toggle state - -// Stores the code for later playback -// Most of this code is just logging -void storeCode(decode_results *results) { - codeType = results->decode_type; - int count = results->rawlen; - if (codeType == UNKNOWN) { - Serial.println("Received unknown code, saving as raw"); - codeLen = results->rawlen - 1; - // To store raw codes: - // Drop first value (gap) - // Convert from ticks to microseconds - // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion - for (int i = 1; i <= codeLen; i++) { - if (i % 2) { - // Mark - rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS; - Serial.print(" m"); - } - else { - // Space - rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS; - Serial.print(" s"); - } - Serial.print(rawCodes[i - 1], DEC); - } - Serial.println(""); - } - else { - if (codeType == NEC) { - Serial.print("Received NEC: "); - if (results->value == REPEAT) { - // Don't record a NEC repeat value as that's useless. - Serial.println("repeat; ignoring."); - return; - } - } - else if (codeType == SONY) { - Serial.print("Received SONY: "); - } - else if (codeType == RC5) { - Serial.print("Received RC5: "); - } - else if (codeType == RC6) { - Serial.print("Received RC6: "); - } - else { - Serial.print("Unexpected codeType "); - Serial.print(codeType, DEC); - Serial.println(""); - } - Serial.println(results->value, HEX); - codeValue = results->value; - codeLen = results->bits; - } -} - -void sendCode(int repeat) { - if (codeType == NEC) { - if (repeat) { - irsend.sendNEC(REPEAT, codeLen); - Serial.println("Sent NEC repeat"); - } - else { - irsend.sendNEC(codeValue, codeLen); - Serial.print("Sent NEC "); - Serial.println(codeValue, HEX); - } - } - else if (codeType == SONY) { - irsend.sendSony(codeValue, codeLen); - Serial.print("Sent Sony "); - Serial.println(codeValue, HEX); - } - else if (codeType == RC5 || codeType == RC6) { - if (!repeat) { - // Flip the toggle bit for a new button press - toggle = 1 - toggle; - } - // Put the toggle bit into the code to send - codeValue = codeValue & ~(1 << (codeLen - 1)); - codeValue = codeValue | (toggle << (codeLen - 1)); - if (codeType == RC5) { - Serial.print("Sent RC5 "); - Serial.println(codeValue, HEX); - irsend.sendRC5(codeValue, codeLen); - } - else { - irsend.sendRC6(codeValue, codeLen); - Serial.print("Sent RC6 "); - Serial.println(codeValue, HEX); - } - } - else if (codeType == UNKNOWN /* i.e. raw */) { - // Assume 38 KHz - irsend.sendRaw(rawCodes, codeLen, 38); - Serial.println("Sent raw"); - } -} - -int lastButtonState; - -void loop() { - // If button pressed, send the code. - int buttonState = digitalRead(BUTTON_PIN); - if (lastButtonState == HIGH && buttonState == LOW) { - Serial.println("Released"); - irrecv.enableIRIn(); // Re-enable receiver - } - - if (buttonState) { - Serial.println("Pressed, sending"); - digitalWrite(STATUS_PIN, HIGH); - sendCode(lastButtonState == buttonState); - digitalWrite(STATUS_PIN, LOW); - delay(50); // Wait a bit between retransmissions - } - else if (irrecv.decode(&results)) { - digitalWrite(STATUS_PIN, HIGH); - storeCode(&results); - irrecv.resume(); // resume receiver - digitalWrite(STATUS_PIN, LOW); - } - lastButtonState = buttonState; -}
--- a/service/busyboxArduino/IRremote/examples/IRrecvDemo/IRrecvDemo.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv - * An IR detector/demodulator must be connected to the input RECV_PIN. - * Version 0.1 July, 2009 - * Copyright 2009 Ken Shirriff - * http://arcfn.com - */ - -#include <IRremote.h> - -int RECV_PIN = 11; - -IRrecv irrecv(RECV_PIN); - -decode_results results; - -void setup() -{ - Serial.begin(9600); - irrecv.enableIRIn(); // Start the receiver -} - -void loop() { - if (irrecv.decode(&results)) { - Serial.println(results.value, HEX); - irrecv.resume(); // Receive the next value - } - delay(100); -}
--- a/service/busyboxArduino/IRremote/examples/IRrecvDump/IRrecvDump.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * IRremote: IRrecvDump - dump details of IR codes with IRrecv - * An IR detector/demodulator must be connected to the input RECV_PIN. - * Version 0.1 July, 2009 - * Copyright 2009 Ken Shirriff - * http://arcfn.com - * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) - * LG added by Darryl Smith (based on the JVC protocol) - */ - -#include <IRremote.h> - -int RECV_PIN = 11; - -IRrecv irrecv(RECV_PIN); - -decode_results results; - -void setup() -{ - Serial.begin(9600); - irrecv.enableIRIn(); // Start the receiver -} - -// Dumps out the decode_results structure. -// Call this after IRrecv::decode() -// void * to work around compiler issue -//void dump(void *v) { -// decode_results *results = (decode_results *)v -void dump(decode_results *results) { - int count = results->rawlen; - if (results->decode_type == UNKNOWN) { - Serial.print("Unknown encoding: "); - } - else if (results->decode_type == NEC) { - Serial.print("Decoded NEC: "); - } - else if (results->decode_type == SONY) { - Serial.print("Decoded SONY: "); - } - else if (results->decode_type == RC5) { - Serial.print("Decoded RC5: "); - } - else if (results->decode_type == RC6) { - Serial.print("Decoded RC6: "); - } - else if (results->decode_type == PANASONIC) { - Serial.print("Decoded PANASONIC - Address: "); - Serial.print(results->panasonicAddress,HEX); - Serial.print(" Value: "); - } - else if (results->decode_type == LG) { - Serial.print("Decoded LG: "); - } - else if (results->decode_type == JVC) { - Serial.print("Decoded JVC: "); - } - Serial.print(results->value, HEX); - Serial.print(" ("); - Serial.print(results->bits, DEC); - Serial.println(" bits)"); - Serial.print("Raw ("); - Serial.print(count, DEC); - Serial.print("): "); - - for (int i = 0; i < count; i++) { - if ((i % 2) == 1) { - Serial.print(results->rawbuf[i]*USECPERTICK, DEC); - } - else { - Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC); - } - Serial.print(" "); - } - Serial.println(""); -} - - -void loop() { - if (irrecv.decode(&results)) { - Serial.println(results.value, HEX); - dump(&results); - irrecv.resume(); // Receive the next value - } -}
--- a/service/busyboxArduino/IRremote/examples/IRrelay/IRrelay.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv - * An IR detector/demodulator must be connected to the input RECV_PIN. - * Version 0.1 July, 2009 - * Copyright 2009 Ken Shirriff - * http://arcfn.com - */ - -#include <IRremote.h> - -int RECV_PIN = 11; -int RELAY_PIN = 4; - -IRrecv irrecv(RECV_PIN); -decode_results results; - -// Dumps out the decode_results structure. -// Call this after IRrecv::decode() -// void * to work around compiler issue -//void dump(void *v) { -// decode_results *results = (decode_results *)v -void dump(decode_results *results) { - int count = results->rawlen; - if (results->decode_type == UNKNOWN) { - Serial.println("Could not decode message"); - } - else { - if (results->decode_type == NEC) { - Serial.print("Decoded NEC: "); - } - else if (results->decode_type == SONY) { - Serial.print("Decoded SONY: "); - } - else if (results->decode_type == RC5) { - Serial.print("Decoded RC5: "); - } - else if (results->decode_type == RC6) { - Serial.print("Decoded RC6: "); - } - Serial.print(results->value, HEX); - Serial.print(" ("); - Serial.print(results->bits, DEC); - Serial.println(" bits)"); - } - Serial.print("Raw ("); - Serial.print(count, DEC); - Serial.print("): "); - - for (int i = 0; i < count; i++) { - if ((i % 2) == 1) { - Serial.print(results->rawbuf[i]*USECPERTICK, DEC); - } - else { - Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC); - } - Serial.print(" "); - } - Serial.println(""); -} - -void setup() -{ - pinMode(RELAY_PIN, OUTPUT); - pinMode(13, OUTPUT); - Serial.begin(9600); - irrecv.enableIRIn(); // Start the receiver -} - -int on = 0; -unsigned long last = millis(); - -void loop() { - if (irrecv.decode(&results)) { - // If it's been at least 1/4 second since the last - // IR received, toggle the relay - if (millis() - last > 250) { - on = !on; - digitalWrite(RELAY_PIN, on ? HIGH : LOW); - digitalWrite(13, on ? HIGH : LOW); - dump(&results); - } - last = millis(); - irrecv.resume(); // Receive the next value - } -}
--- a/service/busyboxArduino/IRremote/examples/IRsendDemo/IRsendDemo.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend - * An IR LED must be connected to Arduino PWM pin 3. - * Version 0.1 July, 2009 - * Copyright 2009 Ken Shirriff - * http://arcfn.com - */ - -#include <IRremote.h> - -IRsend irsend; - -void setup() -{ - Serial.begin(9600); -} - -void loop() { - if (Serial.read() != -1) { - for (int i = 0; i < 3; i++) { - irsend.sendSony(0xa90, 12); // Sony TV power code - delay(40); - } - } -}
--- a/service/busyboxArduino/IRremote/examples/IRtest/IRtest.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,190 +0,0 @@ -/* - * IRremote: IRtest unittest - * Version 0.1 July, 2009 - * Copyright 2009 Ken Shirriff - * http://arcfn.com - * - * Note: to run these tests, edit IRremote/IRremote.h to add "#define TEST" - * You must then recompile the library by removing IRremote.o and restarting - * the arduino IDE. - */ - -#include <IRremote.h> -#include <IRremoteInt.h> - -// Dumps out the decode_results structure. -// Call this after IRrecv::decode() -// void * to work around compiler issue -//void dump(void *v) { -// decode_results *results = (decode_results *)v -void dump(decode_results *results) { - int count = results->rawlen; - if (results->decode_type == UNKNOWN) { - Serial.println("Could not decode message"); - } - else { - if (results->decode_type == NEC) { - Serial.print("Decoded NEC: "); - } - else if (results->decode_type == SONY) { - Serial.print("Decoded SONY: "); - } - else if (results->decode_type == RC5) { - Serial.print("Decoded RC5: "); - } - else if (results->decode_type == RC6) { - Serial.print("Decoded RC6: "); - } - Serial.print(results->value, HEX); - Serial.print(" ("); - Serial.print(results->bits, DEC); - Serial.println(" bits)"); - } - Serial.print("Raw ("); - Serial.print(count, DEC); - Serial.print("): "); - - for (int i = 0; i < count; i++) { - if ((i % 2) == 1) { - Serial.print(results->rawbuf[i]*USECPERTICK, DEC); - } - else { - Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC); - } - Serial.print(" "); - } - Serial.println(""); -} - -IRrecv irrecv(0); -decode_results results; - -class IRsendDummy : -public IRsend -{ -public: - // For testing, just log the marks/spaces -#define SENDLOG_LEN 128 - int sendlog[SENDLOG_LEN]; - int sendlogcnt; - IRsendDummy() : - IRsend() { - } - void reset() { - sendlogcnt = 0; - } - void mark(int time) { - sendlog[sendlogcnt] = time; - if (sendlogcnt < SENDLOG_LEN) sendlogcnt++; - } - void space(int time) { - sendlog[sendlogcnt] = -time; - if (sendlogcnt < SENDLOG_LEN) sendlogcnt++; - } - // Copies the dummy buf into the interrupt buf - void useDummyBuf() { - int last = SPACE; - irparams.rcvstate = STATE_STOP; - irparams.rawlen = 1; // Skip the gap - for (int i = 0 ; i < sendlogcnt; i++) { - if (sendlog[i] < 0) { - if (last == MARK) { - // New space - irparams.rawbuf[irparams.rawlen++] = (-sendlog[i] - MARK_EXCESS) / USECPERTICK; - last = SPACE; - } - else { - // More space - irparams.rawbuf[irparams.rawlen - 1] += -sendlog[i] / USECPERTICK; - } - } - else if (sendlog[i] > 0) { - if (last == SPACE) { - // New mark - irparams.rawbuf[irparams.rawlen++] = (sendlog[i] + MARK_EXCESS) / USECPERTICK; - last = MARK; - } - else { - // More mark - irparams.rawbuf[irparams.rawlen - 1] += sendlog[i] / USECPERTICK; - } - } - } - if (irparams.rawlen % 2) { - irparams.rawlen--; // Remove trailing space - } - } -}; - -IRsendDummy irsenddummy; - -void verify(unsigned long val, int bits, int type) { - irsenddummy.useDummyBuf(); - irrecv.decode(&results); - Serial.print("Testing "); - Serial.print(val, HEX); - if (results.value == val && results.bits == bits && results.decode_type == type) { - Serial.println(": OK"); - } - else { - Serial.println(": Error"); - dump(&results); - } -} - -void testNEC(unsigned long val, int bits) { - irsenddummy.reset(); - irsenddummy.sendNEC(val, bits); - verify(val, bits, NEC); -} -void testSony(unsigned long val, int bits) { - irsenddummy.reset(); - irsenddummy.sendSony(val, bits); - verify(val, bits, SONY); -} -void testRC5(unsigned long val, int bits) { - irsenddummy.reset(); - irsenddummy.sendRC5(val, bits); - verify(val, bits, RC5); -} -void testRC6(unsigned long val, int bits) { - irsenddummy.reset(); - irsenddummy.sendRC6(val, bits); - verify(val, bits, RC6); -} - -void test() { - Serial.println("NEC tests"); - testNEC(0x00000000, 32); - testNEC(0xffffffff, 32); - testNEC(0xaaaaaaaa, 32); - testNEC(0x55555555, 32); - testNEC(0x12345678, 32); - Serial.println("Sony tests"); - testSony(0xfff, 12); - testSony(0x000, 12); - testSony(0xaaa, 12); - testSony(0x555, 12); - testSony(0x123, 12); - Serial.println("RC5 tests"); - testRC5(0xfff, 12); - testRC5(0x000, 12); - testRC5(0xaaa, 12); - testRC5(0x555, 12); - testRC5(0x123, 12); - Serial.println("RC6 tests"); - testRC6(0xfffff, 20); - testRC6(0x00000, 20); - testRC6(0xaaaaa, 20); - testRC6(0x55555, 20); - testRC6(0x12345, 20); -} - -void setup() -{ - Serial.begin(9600); - test(); -} - -void loop() { -}
--- a/service/busyboxArduino/IRremote/examples/IRtest2/IRtest2.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,290 +0,0 @@ -/* - * Test send/receive functions of IRremote, using a pair of Arduinos. - * - * Arduino #1 should have an IR LED connected to the send pin (3). - * Arduino #2 should have an IR detector/demodulator connected to the - * receive pin (11) and a visible LED connected to pin 3. - * - * The cycle: - * Arduino #1 will wait 2 seconds, then run through the tests. - * It repeats this forever. - * Arduino #2 will wait for at least one second of no signal - * (to synchronize with #1). It will then wait for the same test - * signals. It will log all the status to the serial port. It will - * also indicate status through the LED, which will flash each time a test - * is completed. If there is an error, it will light up for 5 seconds. - * - * The test passes if the LED flashes 19 times, pauses, and then repeats. - * The test fails if the LED lights for 5 seconds. - * - * The test software automatically decides which board is the sender and which is - * the receiver by looking for an input on the send pin, which will indicate - * the sender. You should hook the serial port to the receiver for debugging. - * - * Copyright 2010 Ken Shirriff - * http://arcfn.com - */ - -#include <IRremote.h> - -int RECV_PIN = 11; -int LED_PIN = 3; - -IRrecv irrecv(RECV_PIN); -IRsend irsend; - -decode_results results; - -#define RECEIVER 1 -#define SENDER 2 -#define ERROR 3 - -int mode; - -void setup() -{ - Serial.begin(9600); - // Check RECV_PIN to decide if we're RECEIVER or SENDER - if (digitalRead(RECV_PIN) == HIGH) { - mode = RECEIVER; - irrecv.enableIRIn(); - pinMode(LED_PIN, OUTPUT); - digitalWrite(LED_PIN, LOW); - Serial.println("Receiver mode"); - } - else { - mode = SENDER; - Serial.println("Sender mode"); - } -} - -// Wait for the gap between tests, to synchronize with -// the sender. -// Specifically, wait for a signal followed by a gap of at last gap ms. -void waitForGap(int gap) { - Serial.println("Waiting for gap"); - while (1) { - while (digitalRead(RECV_PIN) == LOW) { - } - unsigned long time = millis(); - while (digitalRead(RECV_PIN) == HIGH) { - if (millis() - time > gap) { - return; - } - } - } -} - -// Dumps out the decode_results structure. -// Call this after IRrecv::decode() -void dump(decode_results *results) { - int count = results->rawlen; - if (results->decode_type == UNKNOWN) { - Serial.println("Could not decode message"); - } - else { - if (results->decode_type == NEC) { - Serial.print("Decoded NEC: "); - } - else if (results->decode_type == SONY) { - Serial.print("Decoded SONY: "); - } - else if (results->decode_type == RC5) { - Serial.print("Decoded RC5: "); - } - else if (results->decode_type == RC6) { - Serial.print("Decoded RC6: "); - } - Serial.print(results->value, HEX); - Serial.print(" ("); - Serial.print(results->bits, DEC); - Serial.println(" bits)"); - } - Serial.print("Raw ("); - Serial.print(count, DEC); - Serial.print("): "); - - for (int i = 0; i < count; i++) { - if ((i % 2) == 1) { - Serial.print(results->rawbuf[i]*USECPERTICK, DEC); - } - else { - Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC); - } - Serial.print(" "); - } - Serial.println(""); -} - - -// Test send or receive. -// If mode is SENDER, send a code of the specified type, value, and bits -// If mode is RECEIVER, receive a code and verify that it is of the -// specified type, value, and bits. For success, the LED is flashed; -// for failure, the mode is set to ERROR. -// The motivation behind this method is that the sender and the receiver -// can do the same test calls, and the mode variable indicates whether -// to send or receive. -void test(char *label, int type, unsigned long value, int bits) { - if (mode == SENDER) { - Serial.println(label); - if (type == NEC) { - irsend.sendNEC(value, bits); - } - else if (type == SONY) { - irsend.sendSony(value, bits); - } - else if (type == RC5) { - irsend.sendRC5(value, bits); - } - else if (type == RC6) { - irsend.sendRC6(value, bits); - } - else { - Serial.print(label); - Serial.println("Bad type!"); - } - delay(200); - } - else if (mode == RECEIVER) { - irrecv.resume(); // Receive the next value - unsigned long max_time = millis() + 30000; - Serial.print(label); - - // Wait for decode or timeout - while (!irrecv.decode(&results)) { - if (millis() > max_time) { - Serial.println("Timeout receiving data"); - mode = ERROR; - return; - } - } - if (type == results.decode_type && value == results.value && bits == results.bits) { - Serial.println (": OK"); - digitalWrite(LED_PIN, HIGH); - delay(20); - digitalWrite(LED_PIN, LOW); - } - else { - Serial.println(": BAD"); - dump(&results); - mode = ERROR; - } - } -} - -// Test raw send or receive. This is similar to the test method, -// except it send/receives raw data. -void testRaw(char *label, unsigned int *rawbuf, int rawlen) { - if (mode == SENDER) { - Serial.println(label); - irsend.sendRaw(rawbuf, rawlen, 38 /* kHz */); - delay(200); - } - else if (mode == RECEIVER ) { - irrecv.resume(); // Receive the next value - unsigned long max_time = millis() + 30000; - Serial.print(label); - - // Wait for decode or timeout - while (!irrecv.decode(&results)) { - if (millis() > max_time) { - Serial.println("Timeout receiving data"); - mode = ERROR; - return; - } - } - - // Received length has extra first element for gap - if (rawlen != results.rawlen - 1) { - Serial.print("Bad raw length "); - Serial.println(results.rawlen, DEC); - mode = ERROR; - return; - } - for (int i = 0; i < rawlen; i++) { - long got = results.rawbuf[i+1] * USECPERTICK; - // Adjust for extra duration of marks - if (i % 2 == 0) { - got -= MARK_EXCESS; - } - else { - got += MARK_EXCESS; - } - // See if close enough, within 25% - if (rawbuf[i] * 1.25 < got || got * 1.25 < rawbuf[i]) { - Serial.println(": BAD"); - dump(&results); - mode = ERROR; - return; - } - - } - Serial.println (": OK"); - digitalWrite(LED_PIN, HIGH); - delay(20); - digitalWrite(LED_PIN, LOW); - } -} - -// This is the raw data corresponding to NEC 0x12345678 -unsigned int sendbuf[] = { /* NEC format */ - 9000, 4500, - 560, 560, 560, 560, 560, 560, 560, 1690, /* 1 */ - 560, 560, 560, 560, 560, 1690, 560, 560, /* 2 */ - 560, 560, 560, 560, 560, 1690, 560, 1690, /* 3 */ - 560, 560, 560, 1690, 560, 560, 560, 560, /* 4 */ - 560, 560, 560, 1690, 560, 560, 560, 1690, /* 5 */ - 560, 560, 560, 1690, 560, 1690, 560, 560, /* 6 */ - 560, 560, 560, 1690, 560, 1690, 560, 1690, /* 7 */ - 560, 1690, 560, 560, 560, 560, 560, 560, /* 8 */ - 560}; - -void loop() { - if (mode == SENDER) { - delay(2000); // Delay for more than gap to give receiver a better chance to sync. - } - else if (mode == RECEIVER) { - waitForGap(1000); - } - else if (mode == ERROR) { - // Light up for 5 seconds for error - digitalWrite(LED_PIN, HIGH); - delay(5000); - digitalWrite(LED_PIN, LOW); - mode = RECEIVER; // Try again - return; - } - - // The test suite. - test("SONY1", SONY, 0x123, 12); - test("SONY2", SONY, 0x000, 12); - test("SONY3", SONY, 0xfff, 12); - test("SONY4", SONY, 0x12345, 20); - test("SONY5", SONY, 0x00000, 20); - test("SONY6", SONY, 0xfffff, 20); - test("NEC1", NEC, 0x12345678, 32); - test("NEC2", NEC, 0x00000000, 32); - test("NEC3", NEC, 0xffffffff, 32); - test("NEC4", NEC, REPEAT, 32); - test("RC51", RC5, 0x12345678, 32); - test("RC52", RC5, 0x0, 32); - test("RC53", RC5, 0xffffffff, 32); - test("RC61", RC6, 0x12345678, 32); - test("RC62", RC6, 0x0, 32); - test("RC63", RC6, 0xffffffff, 32); - - // Tests of raw sending and receiving. - // First test sending raw and receiving raw. - // Then test sending raw and receiving decoded NEC - // Then test sending NEC and receiving raw - testRaw("RAW1", sendbuf, 67); - if (mode == SENDER) { - testRaw("RAW2", sendbuf, 67); - test("RAW3", NEC, 0x12345678, 32); - } - else { - test("RAW2", NEC, 0x12345678, 32); - testRaw("RAW3", sendbuf, 67); - } -}
--- a/service/busyboxArduino/IRremote/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend - * An IR LED must be connected to Arduino PWM pin 3. - * Version 0.1 July, 2009 - * Copyright 2009 Ken Shirriff - * http://arcfn.com - * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) - */ -#include <IRremote.h> - -#define PanasonicAddress 0x4004 // Panasonic address (Pre data) -#define PanasonicPower 0x100BCBD // Panasonic Power button - -#define JVCPower 0xC5E8 - -IRsend irsend; - -void setup() -{ -} - -void loop() { - irsend.sendPanasonic(PanasonicAddress,PanasonicPower); // This should turn your TV on and off - - irsend.sendJVC(JVCPower, 16,0); // hex value, 16 bits, no repeat - delayMicroseconds(50); // see http://www.sbprojects.com/knowledge/ir/jvc.php for information - irsend.sendJVC(JVCPower, 16,1); // hex value, 16 bits, repeat - delayMicroseconds(50); -}
--- a/service/busyboxArduino/IRremote/keywords.txt Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -####################################### -# Syntax Coloring Map For IRremote -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -decode_results KEYWORD1 -IRrecv KEYWORD1 -IRsend KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -blink13 KEYWORD2 -decode KEYWORD2 -enableIRIn KEYWORD2 -resume KEYWORD2 -enableIROut KEYWORD2 -sendNEC KEYWORD2 -sendSony KEYWORD2 -sendSanyo KEYWORD2 -sendMitsubishi KEYWORD2 -sendRaw KEYWORD2 -sendRC5 KEYWORD2 -sendRC6 KEYWORD2 -sendDISH KEYWORD2 -sendSharp KEYWORD2 -sendSharpRaw KEYWORD2 -sendPanasonic KEYWORD2 -sendJVC KEYWORD2 - -# -####################################### -# Constants (LITERAL1) -####################################### - -NEC LITERAL1 -SONY LITERAL1 -SANYO LITERAL1 -MITSUBISHI LITERAL1 -RC5 LITERAL1 -RC6 LITERAL1 -DISH LITERAL1 -SHARP LITERAL1 -PANASONIC LITERAL1 -JVC LITERAL1 -UNKNOWN LITERAL1 -REPEAT LITERAL1
--- a/service/busyboxArduino/IRremote/readme Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -This is the IRremote library for the Arduino. - -To download from github (http://github.com/shirriff/Arduino-IRremote), click on the "Downloads" link in the upper right, click "Download as zip", and get a zip file. Unzip it and rename the directory shirriff-Arduino-IRremote-nnn to IRremote - -To install, move the downloaded IRremote directory to: -arduino-1.x/libraries/IRremote -where arduino-1.x is your Arduino installation directory - -After installation you should have files such as: -arduino-1.x/libraries/IRremote/IRremote.cpp - -For details on the library see the Wiki on github or the blog post http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html - -Copyright 2009-2012 Ken Shirriff
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/FastIO.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Florian Fida on 20/01/12 -// Copyright 2012 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// http://creativecommons.org/licenses/by-sa/3.0/ -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// --------------------------------------------------------------------------- -// fio_shiftOut1 functions are based on Shif1 protocol developed by Roman Black -// (http://www.romanblack.com/shift1.htm) -// -// Thread Safe: No -// Extendable: Yes -// -// @file FastIO.h -// This file implements basic fast IO routines. -// -// @brief -// -// @version API 1.0.0 -// -// @author Florian Fida - -// -// 2012-03-16 bperrybap updated fio_shiftout() to be smaller & faster -// -// @todo: -// support chipkit: -// (https://github.com/chipKIT32/chipKIT32-MAX/blob/master/hardware/pic32/ -// cores/pic32/wiring_digital.c) -// --------------------------------------------------------------------------- -#include "FastIO.h" - - -fio_register fio_pinToOutputRegister(uint8_t pin, uint8_t initial_state) -{ - pinMode(pin, OUTPUT); - - if(initial_state != SKIP) - { - digitalWrite(pin, initial_state); // also turns off pwm timer - } -#ifdef FIO_FALLBACK - // just wasting memory if not using fast io... - return 0; -#else - return portOutputRegister(digitalPinToPort(pin)); -#endif -} - - -fio_register fio_pinToInputRegister(uint8_t pin) -{ - pinMode(pin, INPUT); - digitalWrite(pin, LOW); // also turns off pwm timer and pullup -#ifdef FIO_FALLBACK - // just wasting memory if not using fast io... - return 0; -#else - return portInputRegister(digitalPinToPort(pin)); -#endif -} - - -fio_bit fio_pinToBit(uint8_t pin) -{ -#ifdef FIO_FALLBACK - // (ab)use the bit variable to store the pin - return pin; -#else - return digitalPinToBitMask(pin); -#endif -} - - -void fio_digitalWrite(fio_register pinRegister, fio_bit pinBit, uint8_t value) -{ -#ifdef FIO_FALLBACK - digitalWrite(pinBit, value); -#else - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - if(value == LOW) - { - fio_digitalWrite_LOW(pinRegister,pinBit); - } - else - { - fio_digitalWrite_HIGH(pinRegister,pinBit); - } - } -#endif -} - -int fio_digitalRead(fio_register pinRegister, uint8_t pinBit) -{ -#ifdef FIO_FALLBACK - return digitalRead (pinBit); -#else - if (*pinRegister & pinBit) - { - return HIGH; - } - return LOW; -#endif -} - -void fio_shiftOut (fio_register dataRegister, fio_bit dataBit, - fio_register clockRegister, fio_bit clockBit, - uint8_t value, uint8_t bitOrder) -{ - // # disable interrupts - int8_t i; - - if(bitOrder == LSBFIRST) - { - for(i = 0; i < 8; i++) - { - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - if(value & 1) - { - fio_digitalWrite_HIGH(dataRegister, dataBit); - } - else - { - fio_digitalWrite_LOW(dataRegister, dataBit); - } - value >>= 1; - fio_digitalWrite_HIGH (clockRegister, clockBit); - fio_digitalWrite_LOW (clockRegister,clockBit); - } - } - - } - else - { - for(i = 0; i < 8; i++) - { - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - if(value & 0x80) - { - fio_digitalWrite_HIGH(dataRegister, dataBit); - } - else - { - fio_digitalWrite_LOW(dataRegister, dataBit); - } - value <<= 1; - fio_digitalWrite_HIGH (clockRegister, clockBit); - fio_digitalWrite_LOW (clockRegister,clockBit); - } - } - } -} - - -void fio_shiftOut(fio_register dataRegister, fio_bit dataBit, - fio_register clockRegister, fio_bit clockBit) -{ - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - // shift out 0x0 (B00000000) fast, byte order is irrelevant - fio_digitalWrite_LOW (dataRegister, dataBit); - - for(uint8_t i = 0; i<8; ++i) - { - fio_digitalWrite_HIGH (clockRegister, clockBit); - fio_digitalWrite_SWITCH (clockRegister, clockBit); - } - } -} - - -void fio_shiftOut1_init(uint8_t pin) -{ - fio_shiftOut1_init(fio_pinToOutputRegister(pin,HIGH),fio_pinToBit(pin)); -} - -void fio_shiftOut1_init(fio_register shift1Register, fio_bit shift1Bit) -{ - // Make sure that capacitors are charged - // 300us is an educated guess... - fio_digitalWrite(shift1Register,shift1Bit,HIGH); - delayMicroseconds(300); -} - - -void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value, - boolean noLatch) -{ - /* - * this function are based on Shif1 protocol developed by Roman Black - * (http://www.romanblack.com/shift1.htm) - * - * test sketches: - * http://pastebin.com/raw.php?i=2hnC9v2Z - * http://pastebin.com/raw.php?i=bGg4DhXQ - * http://pastebin.com/raw.php?i=tg1ZFiM5 - * http://pastebin.com/raw.php?i=93ExPDD3 - cascading - * tested with: - * TPIC6595N - seems to work fine (circuit: http://www.3guys1laser.com/ - * arduino-one-wire-shift-register-prototype) - * 7HC595N - */ - - // iterate but ignore last bit (is it correct now?) - for(int8_t i = 7; i>=0; --i) - { - - // assume that pin is HIGH (smokin' pot all day... :) - requires - // initialization - if(value & _BV(i)) - { - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - // HIGH = 1 Bit - fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW); - //hold pin LOW for 1us - done! :) - fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,HIGH); - } // end critical section - //hold pin HIGH for 15us - delayMicroseconds(15); - } - else - { - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - // LOW = 0 Bit - fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW); - // hold pin LOW for 15us - delayMicroseconds(15); - fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,HIGH); - } // end critical section - - // hold pin HIGH for 30us - delayMicroseconds(30); - } - if(!noLatch && i==1) - { - break; - } - } - - if(!noLatch) - { - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - // send last bit (=LOW) and Latch command - fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW); - } // end critical section - delayMicroseconds(199); // Hold pin low for 200us - - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - fio_digitalWrite_HIGH(shift1Register,shift1Bit); - } // end critical section - delayMicroseconds(299); // Hold pin high for 300us and leave it that - // way - using explicit HIGH here, just in case. - } -} - -void fio_shiftOut1(uint8_t pin, uint8_t value, boolean noLatch) -{ - fio_shiftOut1(fio_pinToOutputRegister(pin, SKIP),fio_pinToBit(pin),value, noLatch); -}
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/FastIO.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,219 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Florian Fida on 20/01/12 -// Copyright 2012 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// http://creativecommons.org/licenses/by-sa/3.0/ -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// --------------------------------------------------------------------------- -// fio_shiftOut1 functions are based on Shif1 protocol developed by Roman Black -// (http://www.romanblack.com/shift1.htm) -// -// Thread Safe: No -// Extendable: Yes -// -// @file FastIO.h -// This file implements basic fast IO routines. -// -// @brief -// -// @version API 1.0.0 -// -// @author Florian Fida - -// 2012-03-16 bperrybap mods for chipkit32 (pic32) Arduino -// support chipkit: -// (https://github.com/chipKIT32/chipKIT32-MAX/blob/master/hardware/pic32/ -// cores/pic32/wiring_digital.c) -// --------------------------------------------------------------------------- -#ifndef _FAST_IO_H_ -#define _FAST_IO_H_ - -#if (ARDUINO < 100) -#include <WProgram.h> -#else -#include <Arduino.h> -#endif - -#include <pins_arduino.h> // pleasing sanguino core -#include <inttypes.h> - - -#define SKIP 0x23 - -#if defined (__AVR__) -#include <util/atomic.h> // for critical section management -typedef uint8_t fio_bit; -typedef volatile uint8_t *fio_register; - - -#elif defined(__PIC32MX__) -typedef uint32_t fio_bit; -typedef volatile uint32_t *fio_register; - - -#else -// fallback to Arduino standard digital i/o routines -#define FIO_FALLBACK -#define ATOMIC_BLOCK(dummy) if(true) -#define ATOMIC_RESTORESTATE -typedef uint8_t fio_bit; -typedef uint8_t fio_register; -#endif - - - -#if !defined(FIO_FALLBACK) && !defined(ATOMIC_BLOCK) -/* - * Define an ATOMIC_BLOCK that implements ATOMIC_FORCEON type - * Using the portable Arduino interrupts() and noInterrupts() - */ -#define ATOMIC_RESTORESTATE ATOMIC_FORCEON // sorry, no support for save/restore yet. -#define ATOMIC_FORCEON uint8_t sreg_save \ - __attribute__((__cleanup__(__iSeiParam))) = 0 - -static __inline__ uint8_t __iCliRetVal(void) -{ - noInterrupts(); - return(1); -} -static __inline__ void __iSeiParam(const uint8_t *__s) -{ - interrupts(); -} -#define ATOMIC_BLOCK(type) for(type, __Todo = __iCliRetVal(); __Todo; __Todo = 0) - -#endif // end of block to create compatible ATOMIC_BLOCK() - - - -/*! - @function - @abstract Get the output register for specified pin. - @discussion if fast digital IO is disabled this function returns NULL - @param pin[in] Number of a digital pin - @result Register - */ -fio_register fio_pinToOutputRegister(uint8_t pin, uint8_t initial_state = LOW); - -/*! - @function - @abstract Get the input register for specified pin. - @discussion if fast digital IO is disabled this function returns NULL - @param pin[in] Number of a digital pin - @result Register - */ -fio_register fio_pinToInputRegister(uint8_t pin); - -/*! - @function - @abstract Find the bit which belongs to specified pin - @discussion if fast digitalWrite is disabled this function returns the pin - @param pin[in] Number of a digital pin - @result Bit - */ -fio_bit fio_pinToBit(uint8_t pin); - - -/*! - @method - @abstract direct digital write - @discussion without any checks - @discussion falls back to normal digitalWrite if fast io is disabled - @param pinRegister[in] Register - ignored if fast digital write is disabled - @param pinBit[in] Bit - Pin if fast digital write is disabled - @param value[in] desired output - */ -// __attribute__ ((always_inline)) /* let the optimizer decide that for now */ -void fio_digitalWrite ( fio_register pinRegister, fio_bit pinBit, uint8_t value ); - -/** - * This is where the magic happens that makes things fast. - * Implemented as preprocessor directives to force inlining - * SWITCH is fast for FIO but probably slow for FIO_FALLBACK so SWITCHTO is recommended if the value is known. - */ - -#ifndef FIO_FALLBACK -#define fio_digitalWrite_LOW(reg,bit) *reg &= ~bit -#define fio_digitalWrite_HIGH(reg,bit) *reg |= bit -#define fio_digitalWrite_SWITCH(reg,bit) *reg ^= bit -#define fio_digitalWrite_SWITCHTO(reg,bit,val) fio_digitalWrite_SWITCH(reg,bit) -#else -// reg -> dummy NULL, bit -> pin -#define fio_digitalWrite_HIGH(reg,bit) digitalWrite(bit,HIGH) -#define fio_digitalWrite_LOW(reg,bit) digitalWrite(bit,LOW) -#define fio_digitalWrite_SWITCH(reg,bit) digitalWrite(bit, !digitalRead(bit)) -#define fio_digitalWrite_SWITCHTO(reg,bit,val) digitalWrite(bit,val); -#endif - -/*! - @function - @abstract direct digital read - @discussion without any checks - @discussion falls back to normal digitalRead if fast io is disabled - @param pinRegister[in] Register - ignored if fast io is disabled - @param pinBit[in] Bit - Pin if fast io is disabled - @result Value read from pin - */ -int fio_digitalRead ( fio_register pinRegister, fio_bit pinBit ); - -/*! - @method - @abstract faster shift out - @discussion using fast digital write - @discussion falls back to normal digitalWrite if fastio is disabled - @param dataRegister[in] Register of data pin - ignored if fast digital write is disabled - @param dataBit[in] Bit of data pin - Pin if fast digital write is disabled - @param clockRegister[in] Register of data pin - ignored if fast digital write is disabled - @param clockBit[in] Bit of data pin - Pin if fast digital write is disabled - @param bitOrder[in] bit order - */ -void fio_shiftOut( fio_register dataRegister, fio_bit dataBit, fio_register clockRegister, - fio_bit clockBit, uint8_t value, uint8_t bitOrder ); - -/*! - @method - @abstract faster shift out clear - @discussion using fast digital write - @discussion falls back to normal digitalWrite if fastio is disabled - @param dataRegister[in] Register of data pin - ignored if fast digital write is disabled - @param dataBit[in] Bit of data pin - Pin if fast digital write is disabled - @param clockRegister[in] Register of data pin - ignored if fast digital write is disabled - @param clockBit[in] Bit of data pin - Pin if fast digital write is disabled - */ -void fio_shiftOut(fio_register dataRegister, fio_bit dataBit, fio_register clockRegister, fio_bit clockBit); - -/*! - * @method - * @abstract one wire shift out - * @discussion protocol needs initialisation (fio_shiftOut1_init) - * @param shift1Register[in] pins register - * @param shift1Bit[in] pins bit - * @param value[in] value to shift out, last byte is ignored and always shifted out LOW - */ -void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value, boolean noLatch = false); -/*! - * @method - * @abstract one wire shift out - * @discussion protocol needs initialisation (fio_shiftOut1_init) - * @param pin[in] digital pin - * @param value[in] value to shift out, last byte is ignored and always shifted out LOW - */ -void fio_shiftOut1(uint8_t pin, uint8_t value, boolean noLatch = false); -/*! - * @method - * @abstract initializes one wire shift out protocol - * @discussion Puts pin to HIGH state and delays until Capacitors are charged. - * @param shift1Register[in] pins register - * @param shift1Bit[in] pins bit - */ -void fio_shiftOut1_init(fio_register shift1Register, fio_bit shift1Bit); -/*! - * @method - * @abstract initializes one wire shift out protocol - * @discussion Puts pin to HIGH state and delays until Capacitors are charged. - * @param pin[in] digital pin - */ -void fio_shiftOut1_init(uint8_t pin); - -#endif // FAST_IO_H
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/I2CIO.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,198 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file I2CIO.h -// This file implements a basic IO library using the PCF8574 I2C IO Expander -// chip. -// -// @brief -// Implement a basic IO library to drive the PCF8574* I2C IO Expander ASIC. -// The library implements basic IO general methods to configure IO pin direction -// read and write uint8_t operations and basic pin level routines to set or read -// a particular IO port. -// -// -// @version API 1.0.0 -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#if (ARDUINO < 100) -#include <WProgram.h> -#else -#include <Arduino.h> -#endif - -#include <inttypes.h> - -#include <../Wire/Wire.h> -#include "I2CIO.h" - -// CLASS VARIABLES -// --------------------------------------------------------------------------- - - -// CONSTRUCTOR -// --------------------------------------------------------------------------- -I2CIO::I2CIO ( ) -{ - _i2cAddr = 0x0; - _dirMask = 0xFF; // mark all as INPUTs - _shadow = 0x0; // no values set - _initialised = false; -} - -// PUBLIC METHODS -// --------------------------------------------------------------------------- - -// -// begin -int I2CIO::begin ( uint8_t i2cAddr ) -{ - _i2cAddr = i2cAddr; - - Wire.begin ( ); - - _initialised = Wire.requestFrom ( _i2cAddr, (uint8_t)1 ); - -#if (ARDUINO < 100) - _shadow = Wire.receive (); -#else - _shadow = Wire.read (); // Remove the byte read don't need it. -#endif - - return ( _initialised ); -} - -// -// pinMode -void I2CIO::pinMode ( uint8_t pin, uint8_t dir ) -{ - if ( _initialised ) - { - if ( OUTPUT == dir ) - { - _dirMask &= ~( 1 << pin ); - } - else - { - _dirMask |= ( 1 << pin ); - } - } -} - -// -// portMode -void I2CIO::portMode ( uint8_t dir ) -{ - - if ( _initialised ) - { - if ( dir == INPUT ) - { - _dirMask = 0xFF; - } - else - { - _dirMask = 0x00; - } - } -} - -// -// read -uint8_t I2CIO::read ( void ) -{ - uint8_t retVal = 0; - - if ( _initialised ) - { - Wire.requestFrom ( _i2cAddr, (uint8_t)1 ); -#if (ARDUINO < 100) - retVal = ( _dirMask & Wire.receive ( ) ); -#else - retVal = ( _dirMask & Wire.read ( ) ); -#endif - - } - return ( retVal ); -} - -// -// write -int I2CIO::write ( uint8_t value ) -{ - int status = 0; - - if ( _initialised ) - { - // Only write HIGH the values of the ports that have been initialised as - // outputs updating the output shadow of the device - _shadow = ( value & ~(_dirMask) ); - - Wire.beginTransmission ( _i2cAddr ); -#if (ARDUINO < 100) - Wire.send ( _shadow ); -#else - Wire.write ( _shadow ); -#endif - status = Wire.endTransmission (); - } - return ( (status == 0) ); -} - -// -// digitalRead -uint8_t I2CIO::digitalRead ( uint8_t pin ) -{ - uint8_t pinVal = 0; - - // Check if initialised and that the pin is within range of the device - // ------------------------------------------------------------------- - if ( ( _initialised ) && ( pin <= 7 ) ) - { - // Remove the values which are not inputs and get the value of the pin - pinVal = this->read() & _dirMask; - pinVal = ( pinVal >> pin ) & 0x01; // Get the pin value - } - return (pinVal); -} - -// -// digitalWrite -int I2CIO::digitalWrite ( uint8_t pin, uint8_t level ) -{ - uint8_t writeVal; - int status = 0; - - // Check if initialised and that the pin is within range of the device - // ------------------------------------------------------------------- - if ( ( _initialised ) && ( pin <= 7 ) ) - { - // Only write to HIGH the port if the port has been configured as - // an OUTPUT pin. Add the new state of the pin to the shadow - writeVal = ( 1 << pin ) & ~_dirMask; - if ( level == HIGH ) - { - _shadow |= writeVal; - - } - else - { - _shadow &= ~writeVal; - } - status = this->write ( _shadow ); - } - return ( status ); -} - -// -// PRIVATE METHODS -// ---------------------------------------------------------------------------
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/I2CIO.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file I2CIO.h -// This file implements a basic IO library using the PCF8574 I2C IO Expander -// chip. -// -// @brief -// Implement a basic IO library to drive the PCF8574* I2C IO Expander ASIC. -// The library implements basic IO general methods to configure IO pin direction -// read and write uint8_t operations and basic pin level routines to set or read -// a particular IO port. -// -// @version API 1.0.0 -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- - -#ifndef _I2CIO_H_ -#define _I2CIO_H_ - -#include <inttypes.h> - -#define _I2CIO_VERSION "1.0.0" - -/*! - @class - @abstract I2CIO - @discussion Library driver to control PCF8574 based ASICs. Implementing - library calls to set/get port through I2C bus. - */ - -class I2CIO -{ -public: - /*! - @method - @abstract Constructor method - @discussion Class constructor constructor. - */ - I2CIO ( ); - - /*! - @method - @abstract Initializes the device. - @discussion This method initializes the device allocating an I2C address. - This method is the first method that should be call prior to calling any - other method form this class. On initialization all pins are configured - as INPUT on the device. - - @param i2cAddr: I2C Address where the device is located. - @result 1 if the device was initialized correctly, 0 otherwise - */ - int begin ( uint8_t i2cAddr ); - - /*! - @method - @abstract Sets the mode of a particular pin. - @discussion Sets the mode of a particular pin to INPUT, OUTPUT. digitalWrite - has no effect on pins which are not declared as output. - - @param pin[in] Pin from the I2C IO expander to be configured. Range 0..7 - @param dir[in] Pin direction (INPUT, OUTPUT). - */ - void pinMode ( uint8_t pin, uint8_t dir ); - - /*! - @method - @abstract Sets all the pins of the device in a particular direction. - @discussion This method sets all the pins of the device in a particular - direction. This method is useful to set all the pins of the device to be - either inputs or outputs. - @param dir[in] Direction of all the pins of the device (INPUT, OUTPUT). - */ - void portMode ( uint8_t dir ); - - /*! - @method - @abstract Reads all the pins of the device that are configured as INPUT. - @discussion Reads from the device the status of the pins that are configured - as INPUT. During initialization all pins are configured as INPUTs by default. - Please refer to pinMode or portMode. - - @param none - */ - uint8_t read ( void ); - - /*! - @method - @abstract Read a pin from the device. - @discussion Reads a particular pin from the device. To read a particular - pin it has to be configured as INPUT. During initialization all pins are - configured as INPUTs by default. Please refer to pinMode or portMode. - - @param pin[in] Pin from the port to read its status. Range (0..7) - @result Returns the pin status (HIGH, LOW) if the pin is configured - as an output, reading its value will always return LOW regardless of its - real state. - */ - uint8_t digitalRead ( uint8_t pin ); - - /*! - @method - @abstract Write a value to the device. - @discussion Writes to a set of pins in the device. The value is the binary - representation of all the pins in device. The value written is masked with - the configuration of the direction of the pins; to change the state of - a particular pin with this method, such pin has to be configured as OUTPUT - using the portMode or pinMode methods. If no pins have been configured as - OUTPUTs this method will have no effect. - - @param value[in] value to be written to the device. - @result 1 on success, 0 otherwise - */ - int write ( uint8_t value ); - - /*! - @method - @abstract Writes a digital level to a particular pin. - @discussion Write a level to the indicated pin of the device. For this - method to have effect, the pin has to be configured as OUTPUT using the - pinMode or portMode methods. - - @param pin[in] device pin to change level. Range (0..7). - @para level[in] logic level to set the pin at (HIGH, LOW). - @result 1 on success, 0 otherwise. - */ - int digitalWrite ( uint8_t pin, uint8_t level ); - - - -private: - uint8_t _shadow; // Shadow output - uint8_t _dirMask; // Direction mask - uint8_t _i2cAddr; // I2C address - bool _initialised; // Initialised object - -}; - -#endif \ No newline at end of file
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LCD.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,347 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LCD.cpp -// This file implements a basic liquid crystal library that comes as standard -// in the Arduino SDK. -// -// @brief -// This is a basic implementation of the HD44780 library of the -// Arduino SDK. This library is a refactored version of the one supplied -// in the Arduino SDK in such a way that it simplifies its extension -// to support other mechanism to communicate to LCDs such as I2C, Serial, SR, ... -// The original library has been reworked in such a way that this will be -// the base class implementing all generic methods to command an LCD based -// on the Hitachi HD44780 and compatible chipsets. -// -// This base class is a pure abstract class and needs to be extended. As reference, -// it has been extended to drive 4 and 8 bit mode control, LCDs and I2C extension -// backpacks such as the I2CLCDextraIO using the PCF8574* I2C IO Expander ASIC. -// -// -// @version API 1.1.0 -// -// 2012.03.29 bperrybap - changed comparision to use LCD_5x8DOTS rather than 0 -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#include <stdio.h> -#include <string.h> -#include <inttypes.h> - -#if (ARDUINO < 100) -#include <WProgram.h> -#else -#include <Arduino.h> -#endif -#include "LCD.h" - -// CLASS CONSTRUCTORS -// --------------------------------------------------------------------------- -// Constructor -LCD::LCD () -{ - -} - -// PUBLIC METHODS -// --------------------------------------------------------------------------- -// When the display powers up, it is configured as follows: -// -// 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift -// -// Note, however, that resetting the Arduino doesn't reset the LCD, so we -// can't assume that its in that state when a sketch starts (and the -// LiquidCrystal constructor is called). -// A call to begin() will reinitialize the LCD. -// -void LCD::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) -{ - if (lines > 1) - { - _displayfunction |= LCD_2LINE; - } - _numlines = lines; - _cols = cols; - - // for some 1 line displays you can select a 10 pixel high font - // ------------------------------------------------------------ - if ((dotsize != LCD_5x8DOTS) && (lines == 1)) - { - _displayfunction |= LCD_5x10DOTS; - } - - // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! - // according to datasheet, we need at least 40ms after power rises above 2.7V - // before sending commands. Arduino can turn on way before 4.5V so we'll wait - // 50 - // --------------------------------------------------------------------------- - delay (100); // 100ms delay - - //put the LCD into 4 bit or 8 bit mode - // ------------------------------------- - if (! (_displayfunction & LCD_8BITMODE)) - { - // this is according to the hitachi HD44780 datasheet - // figure 24, pg 46 - - // we start in 8bit mode, try to set 4 bit mode - send(0x03, FOUR_BITS); - delayMicroseconds(4500); // wait min 4.1ms - - // second try - send ( 0x03, FOUR_BITS ); - delayMicroseconds(4500); // wait min 4.1ms - - // third go! - send( 0x03, FOUR_BITS ); - delayMicroseconds(150); - - // finally, set to 4-bit interface - send ( 0x02, FOUR_BITS ); - } - else - { - // this is according to the hitachi HD44780 datasheet - // page 45 figure 23 - - // Send function set command sequence - command(LCD_FUNCTIONSET | _displayfunction); - delayMicroseconds(4500); // wait more than 4.1ms - - // second try - command(LCD_FUNCTIONSET | _displayfunction); - delayMicroseconds(150); - - // third go - command(LCD_FUNCTIONSET | _displayfunction); - } - - // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); - - // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; - display(); - - // clear the LCD - clear(); - - // Initialize to default text direction (for romance languages) - _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; - // set the entry mode - command(LCD_ENTRYMODESET | _displaymode); - - backlight(); - -} - -// Common LCD Commands -// --------------------------------------------------------------------------- -void LCD::clear() -{ - command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero - delayMicroseconds(HOME_CLEAR_EXEC); // this command is time consuming -} - -void LCD::home() -{ - command(LCD_RETURNHOME); // set cursor position to zero - delayMicroseconds(HOME_CLEAR_EXEC); // This command is time consuming -} - -void LCD::setCursor(uint8_t col, uint8_t row) -{ - const byte row_offsetsDef[] = { 0x00, 0x40, 0x14, 0x54 }; // For regular LCDs - const byte row_offsetsLarge[] = { 0x00, 0x40, 0x10, 0x50 }; // For 16x4 LCDs - - if ( row >= _numlines ) - { - row = _numlines-1; // rows start at 0 - } - - // 16x4 LCDs have special memory map layout - // ---------------------------------------- - if ( _cols == 16 && _numlines == 4 ) - { - command(LCD_SETDDRAMADDR | (col + row_offsetsLarge[row])); - } - else - { - command(LCD_SETDDRAMADDR | (col + row_offsetsDef[row])); - } - -} - -// Turn the display on/off -void LCD::noDisplay() -{ - _displaycontrol &= ~LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -void LCD::display() -{ - _displaycontrol |= LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turns the underline cursor on/off -void LCD::noCursor() -{ - _displaycontrol &= ~LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LCD::cursor() -{ - _displaycontrol |= LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turns on/off the blinking cursor -void LCD::noBlink() -{ - _displaycontrol &= ~LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -void LCD::blink() -{ - _displaycontrol |= LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// These commands scroll the display without changing the RAM -void LCD::scrollDisplayLeft(void) -{ - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); -} - -void LCD::scrollDisplayRight(void) -{ - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); -} - -// This is for text that flows Left to Right -void LCD::leftToRight(void) -{ - _displaymode |= LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This is for text that flows Right to Left -void LCD::rightToLeft(void) -{ - _displaymode &= ~LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This method moves the cursor one space to the right -void LCD::moveCursorRight(void) -{ - command(LCD_CURSORSHIFT | LCD_CURSORMOVE | LCD_MOVERIGHT); -} - -// This method moves the cursor one space to the left -void LCD::moveCursorLeft(void) -{ - command(LCD_CURSORSHIFT | LCD_CURSORMOVE | LCD_MOVELEFT); -} - - -// This will 'right justify' text from the cursor -void LCD::autoscroll(void) -{ - _displaymode |= LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'left justify' text from the cursor -void LCD::noAutoscroll(void) -{ - _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// Write to CGRAM of new characters -void LCD::createChar(uint8_t location, uint8_t charmap[]) -{ - location &= 0x7; // we only have 8 locations 0-7 - - command(LCD_SETCGRAMADDR | (location << 3)); - delayMicroseconds(30); - - for (int i=0; i<8; i++) - { - write(charmap[i]); // call the virtual write method - delayMicroseconds(40); - } -} - -// -// Switch on the backlight -void LCD::backlight ( void ) -{ - setBacklight(255); -} - -// -// Switch off the backlight -void LCD::noBacklight ( void ) -{ - setBacklight(0); -} - -// -// Switch fully on the LCD (backlight and LCD) -void LCD::on ( void ) -{ - display(); - backlight(); -} - -// -// Switch fully off the LCD (backlight and LCD) -void LCD::off ( void ) -{ - noBacklight(); - noDisplay(); -} - -// General LCD commands - generic methods used by the rest of the commands -// --------------------------------------------------------------------------- -void LCD::command(uint8_t value) -{ - send(value, COMMAND); -} - -#if (ARDUINO < 100) -void LCD::write(uint8_t value) -{ - send(value, DATA); -} -#else -size_t LCD::write(uint8_t value) -{ - send(value, DATA); - return 1; // assume OK -} -#endif
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LCD.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,536 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LCD.h -// This file implements a basic liquid crystal library that comes as standard -// in the Arduino SDK. -// -// @brief -// This is a basic implementation of the LiquidCrystal library of the -// Arduino SDK. This library is a refactored version of the one supplied -// in the Arduino SDK in such a way that it simplifies its extension -// to support other mechanism to communicate to LCDs such as I2C, Serial, SR, -// The original library has been reworked in such a way that this will be -// the base class implementing all generic methods to command an LCD based -// on the Hitachi HD44780 and compatible chipsets. -// -// This base class is a pure abstract class and needs to be extended. As reference, -// it has been extended to drive 4 and 8 bit mode control, LCDs and I2C extension -// backpacks such as the I2CLCDextraIO using the PCF8574* I2C IO Expander ASIC. -// -// The functionality provided by this class and its base class is identical -// to the original functionality of the Arduino LiquidCrystal library. -// -// @version API 1.1.0 -// -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#ifndef _LCD_H_ -#define _LCD_H_ - -#if (ARDUINO < 100) -#include <WProgram.h> -#else -#include <Arduino.h> -#endif - -#include <inttypes.h> -#include <Print.h> - - -/*! - @defined - @abstract Enables disables fast waits for write operations for LCD - @discussion If defined, the library will avoid doing un-necessary waits. - this can be done, because the time taken by Arduino's slow digitalWrite - operations. If fast digitalIO operations, comment this line out or undefine - the mode. - */ -#ifdef __AVR__ -#define FAST_MODE -#endif - -/*! - @function - @abstract waits for a given time in microseconds (compilation dependent). - @discussion Waits for a given time defined in microseconds depending on - the FAST_MODE define. If the FAST_MODE is defined the call will return - inmediatelly. - @param uSec[in] time in microseconds. - @result None - */ -inline static void waitUsec ( uint16_t uSec ) -{ -#ifndef FAST_MODE - delayMicroseconds ( uSec ); -#endif // FAST_MODE -} - - -/*! - @defined - @abstract All these definitions shouldn't be used unless you are writing - a driver. - @discussion All these definitions are for driver implementation only and - shouldn't be used by applications. - */ -// LCD Commands -// --------------------------------------------------------------------------- -#define LCD_CLEARDISPLAY 0x01 -#define LCD_RETURNHOME 0x02 -#define LCD_ENTRYMODESET 0x04 -#define LCD_DISPLAYCONTROL 0x08 -#define LCD_CURSORSHIFT 0x10 -#define LCD_FUNCTIONSET 0x20 -#define LCD_SETCGRAMADDR 0x40 -#define LCD_SETDDRAMADDR 0x80 - -// flags for display entry mode -// --------------------------------------------------------------------------- -#define LCD_ENTRYRIGHT 0x00 -#define LCD_ENTRYLEFT 0x02 -#define LCD_ENTRYSHIFTINCREMENT 0x01 -#define LCD_ENTRYSHIFTDECREMENT 0x00 - -// flags for display on/off and cursor control -// --------------------------------------------------------------------------- -#define LCD_DISPLAYON 0x04 -#define LCD_DISPLAYOFF 0x00 -#define LCD_CURSORON 0x02 -#define LCD_CURSOROFF 0x00 -#define LCD_BLINKON 0x01 -#define LCD_BLINKOFF 0x00 - -// flags for display/cursor shift -// --------------------------------------------------------------------------- -#define LCD_DISPLAYMOVE 0x08 -#define LCD_CURSORMOVE 0x00 -#define LCD_MOVERIGHT 0x04 -#define LCD_MOVELEFT 0x00 - -// flags for function set -// --------------------------------------------------------------------------- -#define LCD_8BITMODE 0x10 -#define LCD_4BITMODE 0x00 -#define LCD_2LINE 0x08 -#define LCD_1LINE 0x00 -#define LCD_5x10DOTS 0x04 -#define LCD_5x8DOTS 0x00 - - -// Define COMMAND and DATA LCD Rs (used by send method). -// --------------------------------------------------------------------------- -#define COMMAND 0 -#define DATA 1 -#define FOUR_BITS 2 - - -/*! - @defined - @abstract Defines the duration of the home and clear commands - @discussion This constant defines the time it takes for the home and clear - commands in the LCD - Time in microseconds. - */ -#define HOME_CLEAR_EXEC 2000 - -/*! - @defined - @abstract Backlight off constant declaration - @discussion Used in combination with the setBacklight to swith off the - LCD backlight. @set setBacklight -*/ -#define BACKLIGHT_OFF 0 - -/*! - @defined - @abstract Backlight on constant declaration - @discussion Used in combination with the setBacklight to swith on the - LCD backlight. @set setBacklight - */ -#define BACKLIGHT_ON 255 - - -/*! - @typedef - @abstract Define backlight control polarity - @discussion Backlight control polarity. @see setBacklightPin. - */ -typedef enum { POSITIVE, NEGATIVE } t_backlighPol; - -class LCD : public Print -{ -public: - - /*! - @method - @abstract LiquidCrystal abstract constructor. - @discussion LiquidCrystal class abstract constructor needed to create - the base abstract class. - */ - LCD ( ); - - /*! - @function - @abstract LCD initialization. - @discussion Initializes the LCD to a given size (col, row). This methods - initializes the LCD, therefore, it MUST be called prior to using any other - method from this class. - - This method is abstract, a base implementation is available common to all LCD - drivers. Should it not be compatible with some other LCD driver, a derived - implementation should be done on the driver specif class. - - @param cols[in] the number of columns that the display has - @param rows[in] the number of rows that the display has - @param charsize[in] character size, default==LCD_5x8DOTS - */ - virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); - - /*! - @function - @abstract Clears the LCD. - @discussion Clears the LCD screen and positions the cursor in the upper-left - corner. - - This operation is time consuming for the LCD. - - @param none - */ - void clear(); - - /*! - @function - @abstract Sets the cursor to the upper-left corner. - @discussion Positions the cursor in the upper-left of the LCD. - That is, use that location in outputting subsequent text to the display. - To also clear the display, use the clear() function instead. - - This operation is time consuming for the LCD. - - @param none - */ - void home(); - - /*! - @function - @abstract Turns off the LCD display. - @discussion Turns off the LCD display, without losing the text currently - being displayed on it. - - @param none - */ - void noDisplay(); - - /*! - @function - @abstract Turns on the LCD display. - @discussion Turns on the LCD display, after it's been turned off with - noDisplay(). This will restore the text (and cursor location) that was on - the display prior to calling noDisplay(). - - @param none - */ - void display(); - - /*! - @function - @abstract Turns off the blinking of the LCD cursor. - - @param none - */ - void noBlink(); - - /*! - @function - @abstract Display the cursor of the LCD. - @discussion Display the blinking LCD cursor. If used in combination with - the cursor() function, the result will depend on the particular display. - - @param none - */ - void blink(); - - /*! - @function - @abstract Hides the LCD cursor. - - @param none - */ - void noCursor(); - - /*! - @function - @abstract Display the LCD cursor. - @discussion Display the LCD cursor: an underscore (line) at the location - where the next character will be written. - - @param none - */ - void cursor(); - - /*! - @function - @abstract Scrolls the contents of the display (text and cursor) one space - to the left. - - @param none - */ - void scrollDisplayLeft(); - - /*! - @function - @abstract Scrolls the contents of the display (text and cursor) one space - to the right. - - @param none - */ - void scrollDisplayRight(); - - /*! - @function - @abstract Set the direction for text written to the LCD to left-to-right. - @discussion Set the direction for text written to the LCD to left-to-right. - All subsequent characters written to the display will go from left to right, - but does not affect previously-output text. - - This is the default configuration. - - @param none - */ - void leftToRight(); - - /*! - @function - @abstract Set the direction for text written to the LCD to right-to-left. - @discussion Set the direction for text written to the LCD to right-to-left. - All subsequent characters written to the display will go from right to left, - but does not affect previously-output text. - - left-to-right is the default configuration. - - @param none - */ - void rightToLeft(); - - /*! - @function - @abstract Moves the cursor one space to the left. - @discussion - @param none - */ - void moveCursorLeft(); - - - /*! - @function - @abstract Moves the cursor one space to the right. - - @param none - */ - void moveCursorRight(); - - /*! - @function - @abstract Turns on automatic scrolling of the LCD. - @discussion Turns on automatic scrolling of the LCD. This causes each - character output to the display to push previous characters over by one - space. If the current text direction is left-to-right (the default), - the display scrolls to the left; if the current direction is right-to-left, - the display scrolls to the right. - This has the effect of outputting each new character to the same location on - the LCD. - - @param none - */ - void autoscroll(); - - /*! - @function - @abstract Turns off automatic scrolling of the LCD. - @discussion Turns off automatic scrolling of the LCD, this is the default - configuration of the LCD. - - @param none - */ - void noAutoscroll(); - - /*! - @function - @abstract Creates a custom character for use on the LCD. - @discussion Create a custom character (glyph) for use on the LCD. - Most chipsets only support up to eight characters of 5x8 pixels. Therefore, - this methods has been limited to locations (numbered 0 to 7). - - The appearance of each custom character is specified by an array of eight - bytes, one for each row. The five least significant bits of each byte - determine the pixels in that row. To display a custom character on screen, - write()/print() its number, i.e. lcd.print (char(x)); // Where x is 0..7. - - @param location[in] LCD memory location of the character to create - (0 to 7) - @param charmap[in] the bitmap array representing each row of the character. - */ - void createChar(uint8_t location, uint8_t charmap[]); - - /*! - @function - @abstract Position the LCD cursor. - @discussion Sets the position of the LCD cursor. Set the location at which - subsequent text written to the LCD will be displayed. - - @param col[in] LCD column - @param row[in] LCD row - line. - */ - void setCursor(uint8_t col, uint8_t row); - - /*! - @function - @abstract Switch-on the LCD backlight. - @discussion Switch-on the LCD backlight. - The setBacklightPin has to be called before setting the backlight for - this method to work. @see setBacklightPin. - */ - void backlight ( void ); - - /*! - @function - @abstract Switch-off the LCD backlight. - @discussion Switch-off the LCD backlight. - The setBacklightPin has to be called before setting the backlight for - this method to work. @see setBacklightPin. - */ - void noBacklight ( void ); - - /*! - @function - @abstract Switch on the LCD module. - @discussion Switch on the LCD module, it will switch on the LCD controller - and the backlight. This method has the same effect of calling display and - backlight. @see display, @see backlight - */ - void on ( void ); - - /*! - @function - @abstract Switch off the LCD module. - @discussion Switch off the LCD module, it will switch off the LCD controller - and the backlight. This method has the same effect of calling noDisplay and - noBacklight. @see display, @see backlight - */ - void off ( void ); - - // - // virtual class methods - // -------------------------------------------------------------------------- - /*! - @function - @abstract Sets the pin to control the backlight. - @discussion Sets the pin in the device to control the backlight. - This method is device dependent and can be programmed on each subclass. An - empty function call is provided that does nothing. - - @param value: pin associated to backlight control. - @param pol: backlight polarity control (POSITIVE, NEGATIVE) - */ - virtual void setBacklightPin ( uint8_t value, t_backlighPol pol ) { }; - - /*! - @function - @abstract Sets the pin to control the backlight. - @discussion Sets the pin in the device to control the backlight. The behaviour - of this method is very dependent on the device. Some controllers support - dimming some don't. Please read the actual header file for each individual - device. The setBacklightPin method has to be called before setting the backlight - or the adequate backlight control constructor. - @see setBacklightPin. - - NOTE: The prefered methods to control the backlight are "backlight" and - "noBacklight". - - @param 0..255 - the value is very dependent on the LCD. However, - BACKLIGHT_OFF will be interpreted as off and BACKLIGHT_ON will drive the - backlight on. - */ - virtual void setBacklight ( uint8_t value ) { }; - - /*! - @function - @abstract Writes to the LCD. - @discussion This method writes character to the LCD in the current cursor - position. - - This is the virtual write method, implemented in the Print class, therefore - all Print class methods will end up calling this method. - - @param value[in] Value to write to the LCD. - */ -#if (ARDUINO < 100) - virtual void write(uint8_t value); -#else - virtual size_t write(uint8_t value); -#endif - -#if (ARDUINO < 100) - using Print::write; -#else - using Print::write; -#endif - -protected: - // Internal LCD variables to control the LCD shared between all derived - // classes. - uint8_t _displayfunction; // LCD_5x10DOTS or LCD_5x8DOTS, LCD_4BITMODE or - // LCD_8BITMODE, LCD_1LINE or LCD_2LINE - uint8_t _displaycontrol; // LCD base control command LCD on/off, blink, cursor - // all commands are "ored" to its contents. - uint8_t _displaymode; // Text entry mode to the LCD - uint8_t _numlines; // Number of lines of the LCD, initialized with begin() - uint8_t _cols; // Number of columns in the LCD - t_backlighPol _polarity; // Backlight polarity - -private: - /*! - @function - @abstract Send a command to the LCD. - @discussion This method sends a command to the LCD by setting the Register - select line of the LCD. - - This command shouldn't be used to drive the LCD, only to implement any other - feature that is not available on this library. - - @param value[in] Command value to send to the LCD (COMMAND, DATA or - FOUR_BITS). - */ - void command(uint8_t value); - - /*! - @function - @abstract Send a particular value to the LCD. - @discussion Sends a particular value to the LCD. This is a pure abstract - method, therefore, it is implementation dependent of each derived class how - to physically write to the LCD. - - Users should never call this method. - - @param value[in] Value to send to the LCD. - @result mode LOW - write to the LCD CGRAM, HIGH - write a command to - the LCD. - */ -#if (ARDUINO < 100) - virtual void send(uint8_t value, uint8_t mode) { }; -#else - virtual void send(uint8_t value, uint8_t mode) = 0; -#endif - -}; - -#endif
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,299 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal.cpp -// This file implements a basic liquid crystal library that comes as standard -// in the Arduino SDK. -// -// @brief -// This is a basic implementation of the LiquidCrystal library of the -// Arduino SDK. The original library has been reworked in such a way that -// this class implements the all methods to command an LCD based -// on the Hitachi HD44780 and compatible chipsets using the parallel port of -// the LCD (4 bit and 8 bit). -// -// The functionality provided by this class and its base class is identical -// to the original functionality of the Arduino LiquidCrystal library. -// -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#include <stdio.h> -#include <string.h> -#include <inttypes.h> - -#if (ARDUINO < 100) -#include <WProgram.h> -#else -#include <Arduino.h> -#endif -#include "LiquidCrystal.h" - -// CONSTANT definitions -// --------------------------------------------------------------------------- -#define LCD_NOBACKLIGHT 0xFF - -// LCD driver configuration (4bit or 8bit driver control) -#define LCD_4BIT 1 -#define LCD_8BIT 0 - -// STATIC helper functions -// --------------------------------------------------------------------------- - - -// CONSTRUCTORS -// --------------------------------------------------------------------------- - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) -{ - init(LCD_8BIT, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) -{ - init(LCD_8BIT, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) -{ - init(LCD_4BIT, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) -{ - init(LCD_4BIT, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); -} - -// Contructors with backlight control -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t backlightPin, t_backlighPol pol) -{ - init(LCD_8BIT, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); - setBacklightPin ( backlightPin, pol ); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t backlightPin, t_backlighPol pol) -{ - init(LCD_8BIT, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); - setBacklightPin ( backlightPin, pol ); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t backlightPin, t_backlighPol pol) -{ - init(LCD_4BIT, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); - setBacklightPin ( backlightPin, pol ); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t backlightPin, t_backlighPol pol) -{ - init(LCD_4BIT, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); - setBacklightPin ( backlightPin, pol ); -} - -// PUBLIC METHODS -// --------------------------------------------------------------------------- - -/************ low level data pushing commands **********/ -// -// send -void LiquidCrystal::send(uint8_t value, uint8_t mode) -{ - // Only interested in COMMAND or DATA - digitalWrite( _rs_pin, ( mode == DATA ) ); - - // if there is a RW pin indicated, set it low to Write - // --------------------------------------------------- - if (_rw_pin != 255) - { - digitalWrite(_rw_pin, LOW); - } - - if ( mode != FOUR_BITS ) - { - if ( (_displayfunction & LCD_8BITMODE ) ) - { - writeNbits(value, 8); - } - else - { - writeNbits ( value >> 4, 4 ); - writeNbits ( value, 4 ); - } - } - else - { - writeNbits ( value, 4 ); - } - waitUsec ( EXEC_TIME ); // wait for the command to execute by the LCD -} - -// -// setBacklightPin -void LiquidCrystal::setBacklightPin ( uint8_t pin, t_backlighPol pol ) -{ - pinMode ( pin, OUTPUT ); // Difine the backlight pin as output - _backlightPin = pin; - _polarity = pol; - setBacklight(BACKLIGHT_OFF); // Set the backlight low by default -} - -// -// setBackligh -void LiquidCrystal::setBacklight ( uint8_t value ) -{ - // Check if there is a pin assigned to the backlight - // --------------------------------------------------- - if ( _backlightPin != LCD_NOBACKLIGHT ) - { - // Check if the pin is associated to a timer, i.e. PWM - // --------------------------------------------------- - if(digitalPinToTimer(_backlightPin) != NOT_ON_TIMER) - { - // Check for control polarity inversion - // --------------------------------------------------- - if ( _polarity == POSITIVE ) - { - analogWrite ( _backlightPin, value ); - } - else - { - analogWrite ( _backlightPin, 255 - value ); - } - } - // Not a PWM pin, set the backlight pin for POSI or NEG - // polarity - // -------------------------------------------------------- - else if (((value > 0) && (_polarity == POSITIVE)) || - ((value == 0) && (_polarity == NEGATIVE))) - { - digitalWrite( _backlightPin, HIGH); - } - else - { - digitalWrite( _backlightPin, LOW); - } - } -} - -// PRIVATE METHODS -// --------------------------------------------------------------------------- - - -// init -void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) -{ - uint8_t i; - - // Initialize the IO pins - // ----------------------- - - _rs_pin = rs; - _rw_pin = rw; - _enable_pin = enable; - - _data_pins[0] = d0; - _data_pins[1] = d1; - _data_pins[2] = d2; - _data_pins[3] = d3; - _data_pins[4] = d4; - _data_pins[5] = d5; - _data_pins[6] = d6; - _data_pins[7] = d7; - - // Initialize the IO port direction to OUTPUT - // ------------------------------------------ - - for ( i = 0; i < 4; i++ ) - { - pinMode ( _data_pins[i], OUTPUT ); - } - - // Initialize the rest of the ports if it is an 8bit controlled LCD - // ---------------------------------------------------------------- - - if ( !fourbitmode ) - { - for ( i = 4; i < 8; i++ ) - { - pinMode ( _data_pins[i], OUTPUT ); - } - } - pinMode(_rs_pin, OUTPUT); - - // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) - { - pinMode(_rw_pin, OUTPUT); - } - - pinMode(_enable_pin, OUTPUT); - - // Initialise displaymode functions to defaults: LCD_1LINE and LCD_5x8DOTS - // ------------------------------------------------------------------------- - if (fourbitmode) - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else - _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - // Now we pull both RS and R/W low to begin commands - digitalWrite(_rs_pin, LOW); - digitalWrite(_enable_pin, LOW); - - if (_rw_pin != 255) - { - digitalWrite(_rw_pin, LOW); - } - - // Initialise the backlight pin no nothing - _backlightPin = LCD_NOBACKLIGHT; - _polarity = POSITIVE; -} - -// -// pulseEnable -void LiquidCrystal::pulseEnable(void) -{ - // There is no need for the delays, since the digitalWrite operation - // takes longer. - digitalWrite(_enable_pin, HIGH); - waitUsec(1); // enable pulse must be > 450ns - digitalWrite(_enable_pin, LOW); -} - -// -// write4bits -void LiquidCrystal::writeNbits(uint8_t value, uint8_t numBits) -{ - for (uint8_t i = 0; i < numBits; i++) - { - digitalWrite(_data_pins[i], (value >> i) & 0x01); - } - pulseEnable(); -} - -
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal.h -// This file implements a basic liquid crystal library that comes as standard -// in the Arduino SDK. -// -// @brief -// This is a basic implementation of the LiquidCrystal library of the -// Arduino SDK. The original library has been reworked in such a way that -// this class implements the all methods to command an LCD based -// on the Hitachi HD44780 and compatible chipsets using the parallel port of -// the LCD (4 bit and 8 bit). -// -// -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#ifndef LiquidCrystal_4bit_h -#define LiquidCrystal_4bit_h - -#include <inttypes.h> - -#include "LCD.h" -#include "FastIO.h" - - -/*! - @defined - @abstract Command execution time on the LCD. - @discussion This defines how long a command takes to execute by the LCD. - The time is expressed in micro-seconds. - */ -#define EXEC_TIME 37 - -class LiquidCrystal : public LCD -{ -public: - /*! - @method - @abstract 8 bit LCD constructors. - @discussion Defines the pin assignment that the LCD will have. - The constructor does not initialize the LCD. - */ - LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - - // Constructors with backlight control - LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t backlightPin, t_backlighPol pol); - LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t backlightPin, t_backlighPol pol); - /*! - @method - @abstract 4 bit LCD constructors. - @discussion Defines the pin assignment that the LCD will have. - The constructor does not initialize the LCD. - */ - LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); - LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); - - // Constructors with backlight control - LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t backlightPin, t_backlighPol pol); - LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t backlightPin, t_backlighPol pol); - /*! - @function - @abstract Send a particular value to the LCD. - @discussion Sends a particular value to the LCD for writing to the LCD or - as an LCD command. - - Users should never call this method. - - @param value Value to send to the LCD. - @result mode LOW - write to the LCD CGRAM, HIGH - write a command to - the LCD. - */ - virtual void send(uint8_t value, uint8_t mode); - - /*! - @function - @abstract Sets the pin to control the backlight. - @discussion Sets the pin in the device to control the backlight. - - @param pin: pin assigned to the backlight - @param pol: backlight pin control polarity (POSITIVE, NEGATIVE). - */ - void setBacklightPin ( uint8_t pin, t_backlighPol pol ); - - /*! - @function - @abstract Switch-on/off the LCD backlight. - @discussion Switch-on/off the LCD backlight. - The setBacklightPin has to be called before setting the backlight for - this method to work. @see setBacklightPin. For dimming control of the - backlight, the configuration pin must be a PWM output pin. Dim control - is achieved by passing a value from 1 to 255 as a parameter. If the - pin configured when calling the setBacklightPin does not support PWM, - then: (0) backlight off, (1..255) backlight on. - - @param value: backlight value. 0: off, 1..255: dim control of the - backlight. For negative logic 255: off, 254..0: dim control. - */ - void setBacklight ( uint8_t value ); - -private: - - /*! - @method - @abstract Initializes the LCD pin allocation and associated HW - @discussion Initializes the LCD pin allocation and configuration. - */ - void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - - /*! - @method - @abstract Writes numBits bits from value value to the LCD. - @discussion Writes numBists bits (the least significant) to the LCD control - data lines. - */ - void writeNbits(uint8_t value, uint8_t numBits); - - /*! - @method - @abstract Pulse the LCD enable line (En). - @discussion Sends a pulse of 1 uS to the Enable pin to execute an command - or write operation. - */ - void pulseEnable(); - - uint8_t _rs_pin; // LOW: command. HIGH: character. - uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. - uint8_t _enable_pin; // activated by a HIGH pulse. - uint8_t _data_pins[8]; // Data pins. - uint8_t _backlightPin; // Pin associated to control the LCD backlight -}; - -#endif
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_I2C.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,291 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal_I2C.c -// This file implements a basic liquid crystal library that comes as standard -// in the Arduino SDK but using an I2C IO extension board. -// -// @brief -// This is a basic implementation of the LiquidCrystal library of the -// Arduino SDK. The original library has been reworked in such a way that -// this class implements the all methods to command an LCD based -// on the Hitachi HD44780 and compatible chipsets using I2C extension -// backpacks such as the I2CLCDextraIO with the PCF8574* I2C IO Expander ASIC. -// -// The functionality provided by this class and its base class is identical -// to the original functionality of the Arduino LiquidCrystal library. -// -// -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#if (ARDUINO < 100) -#include <WProgram.h> -#else -#include <Arduino.h> -#endif -#include <inttypes.h> -#include "I2CIO.h" -#include "LiquidCrystal_I2C.h" - -// CONSTANT definitions -// --------------------------------------------------------------------------- - -// flags for backlight control -/*! - @defined - @abstract LCD_NOBACKLIGHT - @discussion NO BACKLIGHT MASK - */ -#define LCD_NOBACKLIGHT 0x00 - -/*! - @defined - @abstract LCD_BACKLIGHT - @discussion BACKLIGHT MASK used when backlight is on - */ -#define LCD_BACKLIGHT 0xFF - - -// Default library configuration parameters used by class constructor with -// only the I2C address field. -// --------------------------------------------------------------------------- -/*! - @defined - @abstract Enable bit of the LCD - @discussion Defines the IO of the expander connected to the LCD Enable - */ -#define EN 6 // Enable bit - -/*! - @defined - @abstract Read/Write bit of the LCD - @discussion Defines the IO of the expander connected to the LCD Rw pin - */ -#define RW 5 // Read/Write bit - -/*! - @defined - @abstract Register bit of the LCD - @discussion Defines the IO of the expander connected to the LCD Register select pin - */ -#define RS 4 // Register select bit - -/*! - @defined - @abstract LCD dataline allocation this library only supports 4 bit LCD control - mode. - @discussion D4, D5, D6, D7 LCD data lines pin mapping of the extender module - */ -#define D4 0 -#define D5 1 -#define D6 2 -#define D7 3 - - -// CONSTRUCTORS -// --------------------------------------------------------------------------- -LiquidCrystal_I2C::LiquidCrystal_I2C( uint8_t lcd_Addr ) -{ - config(lcd_Addr, EN, RW, RS, D4, D5, D6, D7); -} - - -LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t backlighPin, - t_backlighPol pol = POSITIVE) -{ - config(lcd_Addr, EN, RW, RS, D4, D5, D6, D7); - setBacklightPin(backlighPin, pol); -} - -LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, - uint8_t Rs) -{ - config(lcd_Addr, En, Rw, Rs, D4, D5, D6, D7); -} - -LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, - uint8_t Rs, uint8_t backlighPin, - t_backlighPol pol = POSITIVE) -{ - config(lcd_Addr, En, Rw, Rs, D4, D5, D6, D7); - setBacklightPin(backlighPin, pol); -} - -LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, - uint8_t Rs, uint8_t d4, uint8_t d5, - uint8_t d6, uint8_t d7 ) -{ - config(lcd_Addr, En, Rw, Rs, d4, d5, d6, d7); -} - -LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, - uint8_t Rs, uint8_t d4, uint8_t d5, - uint8_t d6, uint8_t d7, uint8_t backlighPin, - t_backlighPol pol = POSITIVE ) -{ - config(lcd_Addr, En, Rw, Rs, d4, d5, d6, d7); - setBacklightPin(backlighPin, pol); -} - -// PUBLIC METHODS -// --------------------------------------------------------------------------- - -// -// begin -void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) -{ - - init(); // Initialise the I2C expander interface - LCD::begin ( cols, lines, dotsize ); -} - - -// User commands - users can expand this section -//---------------------------------------------------------------------------- -// Turn the (optional) backlight off/on - -// -// setBacklightPin -void LiquidCrystal_I2C::setBacklightPin ( uint8_t value, t_backlighPol pol = POSITIVE ) -{ - _backlightPinMask = ( 1 << value ); - _polarity = pol; - setBacklight(BACKLIGHT_OFF); -} - -// -// setBacklight -void LiquidCrystal_I2C::setBacklight( uint8_t value ) -{ - // Check if backlight is available - // ---------------------------------------------------- - if ( _backlightPinMask != 0x0 ) - { - // Check for polarity to configure mask accordingly - // ---------------------------------------------------------- - if (((_polarity == POSITIVE) && (value > 0)) || - ((_polarity == NEGATIVE ) && ( value == 0 ))) - { - _backlightStsMask = _backlightPinMask & LCD_BACKLIGHT; - } - else - { - _backlightStsMask = _backlightPinMask & LCD_NOBACKLIGHT; - } - _i2cio.write( _backlightStsMask ); - } -} - - -// PRIVATE METHODS -// --------------------------------------------------------------------------- - -// -// init -int LiquidCrystal_I2C::init() -{ - int status = 0; - - // initialize the backpack IO expander - // and display functions. - // ------------------------------------------------------------------------ - if ( _i2cio.begin ( _Addr ) == 1 ) - { - _i2cio.portMode ( OUTPUT ); // Set the entire IO extender to OUTPUT - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - status = 1; - _i2cio.write(0); // Set the entire port to LOW - } - return ( status ); -} - -// -// config -void LiquidCrystal_I2C::config (uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ) -{ - _Addr = lcd_Addr; - - _backlightPinMask = 0; - _backlightStsMask = LCD_NOBACKLIGHT; - _polarity = POSITIVE; - - _En = ( 1 << En ); - _Rw = ( 1 << Rw ); - _Rs = ( 1 << Rs ); - - // Initialise pin mapping - _data_pins[0] = ( 1 << d4 ); - _data_pins[1] = ( 1 << d5 ); - _data_pins[2] = ( 1 << d6 ); - _data_pins[3] = ( 1 << d7 ); -} - - - -// low level data pushing commands -//---------------------------------------------------------------------------- - -// -// send - write either command or data -void LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) -{ - // No need to use the delay routines since the time taken to write takes - // longer that what is needed both for toggling and enable pin an to execute - // the command. - - if ( mode == FOUR_BITS ) - { - write4bits( (value & 0x0F), COMMAND ); - } - else - { - write4bits( (value >> 4), mode ); - write4bits( (value & 0x0F), mode); - } -} - -// -// write4bits -void LiquidCrystal_I2C::write4bits ( uint8_t value, uint8_t mode ) -{ - uint8_t pinMapValue = 0; - - // Map the value to LCD pin mapping - // -------------------------------- - for ( uint8_t i = 0; i < 4; i++ ) - { - if ( ( value & 0x1 ) == 1 ) - { - pinMapValue |= _data_pins[i]; - } - value = ( value >> 1 ); - } - - // Is it a command or data - // ----------------------- - if ( mode == DATA ) - { - mode = _Rs; - } - - pinMapValue |= mode | _backlightStsMask; - pulseEnable ( pinMapValue ); -} - -// -// pulseEnable -void LiquidCrystal_I2C::pulseEnable (uint8_t data) -{ - _i2cio.write (data | _En); // En HIGH - _i2cio.write (data & ~_En); // En LOW -} \ No newline at end of file
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_I2C.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,204 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal_I2C.h -// This file implements a basic liquid crystal library that comes as standard -// in the Arduino SDK but using an I2C IO extension board. -// -// @brief -// This is a basic implementation of the LiquidCrystal library of the -// Arduino SDK. The original library has been reworked in such a way that -// this class implements the all methods to command an LCD based -// on the Hitachi HD44780 and compatible chipsets using I2C extension -// backpacks such as the I2CLCDextraIO with the PCF8574* I2C IO Expander ASIC. -// -// The functionality provided by this class and its base class is identical -// to the original functionality of the Arduino LiquidCrystal library. -// -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#ifndef LiquidCrystal_I2C_h -#define LiquidCrystal_I2C_h -#include <inttypes.h> -#include <Print.h> - -#include "I2CIO.h" -#include "LCD.h" - - -class LiquidCrystal_I2C : public LCD -{ -public: - - /*! - @method - @abstract Class constructor. - @discussion Initializes class variables and defines the I2C address of the - LCD. The constructor does not initialize the LCD. - - @param lcd_Addr[in] I2C address of the IO expansion module. For I2CLCDextraIO, - the address can be configured using the on board jumpers. - */ - LiquidCrystal_I2C (uint8_t lcd_Addr); - // Constructor with backlight control - LiquidCrystal_I2C (uint8_t lcd_Addr, uint8_t backlighPin, t_backlighPol pol); - - /*! - @method - @abstract Class constructor. - @discussion Initializes class variables and defines the I2C address of the - LCD. The constructor does not initialize the LCD. - - @param lcd_Addr[in] I2C address of the IO expansion module. For I2CLCDextraIO, - the address can be configured using the on board jumpers. - @param En[in] LCD En (Enable) pin connected to the IO extender module - @param Rw[in] LCD Rw (Read/write) pin connected to the IO extender module - @param Rs[in] LCD Rs (Reset) pin connected to the IO extender module - */ - LiquidCrystal_I2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs); - // Constructor with backlight control - LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t backlighPin, t_backlighPol pol); - - /*! - @method - @abstract Class constructor. - @discussion Initializes class variables and defines the I2C address of the - LCD. The constructor does not initialize the LCD. - - @param lcd_Addr[in] I2C address of the IO expansion module. For I2CLCDextraIO, - the address can be configured using the on board jumpers. - @param En[in] LCD En (Enable) pin connected to the IO extender module - @param Rw[in] LCD Rw (Read/write) pin connected to the IO extender module - @param Rs[in] LCD Rs (Reset) pin connected to the IO extender module - @param d4[in] LCD data 0 pin map on IO extender module - @param d5[in] LCD data 1 pin map on IO extender module - @param d6[in] LCD data 2 pin map on IO extender module - @param d7[in] LCD data 3 pin map on IO extender module - */ - LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ); - // Constructor with backlight control - LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t backlighPin, t_backlighPol pol); - /*! - @function - @abstract LCD initialization and associated HW. - @discussion Initializes the LCD to a given size (col, row). This methods - initializes the LCD, therefore, it MUST be called prior to using any other - method from this class or parent class. - - The begin method can be overloaded if necessary to initialize any HW that - is implemented by a library and can't be done during construction, here - we use the Wire class. - - @param cols[in] the number of columns that the display has - @param rows[in] the number of rows that the display has - @param charsize[in] size of the characters of the LCD: LCD_5x8DOTS or - LCD_5x10DOTS. - */ - virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); - - /*! - @function - @abstract Send a particular value to the LCD. - @discussion Sends a particular value to the LCD for writing to the LCD or - as an LCD command. - - Users should never call this method. - - @param value[in] Value to send to the LCD. - @param mode[in] DATA - write to the LCD CGRAM, COMMAND - write a - command to the LCD. - */ - virtual void send(uint8_t value, uint8_t mode); - - /*! - @function - @abstract Sets the pin to control the backlight. - @discussion Sets the pin in the device to control the backlight. This device - doesn't support dimming backlight capability. - - @param 0: backlight off, 1..255: backlight on. - */ - void setBacklightPin ( uint8_t value, t_backlighPol pol ); - - /*! - @function - @abstract Switch-on/off the LCD backlight. - @discussion Switch-on/off the LCD backlight. - The setBacklightPin has to be called before setting the backlight for - this method to work. @see setBacklightPin. - - @param value: backlight mode (HIGH|LOW) - */ - void setBacklight ( uint8_t value ); - -private: - - /*! - @method - @abstract Initializes the LCD class - @discussion Initializes the LCD class and IO expansion module. - */ - int init(); - - /*! - @function - @abstract Initialises class private variables - @discussion This is the class single point for initialising private variables. - - @param lcd_Addr[in] I2C address of the IO expansion module. For I2CLCDextraIO, - the address can be configured using the on board jumpers. - @param En[in] LCD En (Enable) pin connected to the IO extender module - @param Rw[in] LCD Rw (Read/write) pin connected to the IO extender module - @param Rs[in] LCD Rs (Reset) pin connected to the IO extender module - @param d4[in] LCD data 0 pin map on IO extender module - @param d5[in] LCD data 1 pin map on IO extender module - @param d6[in] LCD data 2 pin map on IO extender module - @param d7[in] LCD data 3 pin map on IO extender module - */ - void config (uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ); - - /*! - @method - @abstract Writes an 4 bit value to the LCD. - @discussion Writes 4 bits (the least significant) to the LCD control data lines. - @param value[in] Value to write to the LCD - @param more[in] Value to distinguish between command and data. - COMMAND == command, DATA == data. - */ - void write4bits(uint8_t value, uint8_t mode); - - /*! - @method - @abstract Pulse the LCD enable line (En). - @discussion Sends a pulse of 1 uS to the Enable pin to execute an command - or write operation. - */ - void pulseEnable(uint8_t); - - - uint8_t _Addr; // I2C Address of the IO expander - uint8_t _backlightPinMask; // Backlight IO pin mask - uint8_t _backlightStsMask; // Backlight status mask - I2CIO _i2cio; // I2CIO PCF8574* expansion module driver I2CLCDextraIO - uint8_t _En; // LCD expander word for enable pin - uint8_t _Rw; // LCD expander word for R/W pin - uint8_t _Rs; // LCD expander word for Register Select pin - uint8_t _data_pins[4]; // LCD data lines - -}; - -#endif
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,209 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal_SR.h -// Connects an LCD using 2 or 3 pins from the Arduino, via an 8-bit -// ShiftRegister (SR from now on). -// -// @brief -// This is a port of the ShiftRegLCD library from raron and ported to the -// LCD library. -// -// The functionality provided by this class and its base class is identical -// to the original functionality of the Arduino LiquidCrystal library and can -// be used as such. -// -// Modified to work serially with the shiftOut() function, an 8-bit -// unlatched, no-tristate, unidirectional SIPO (Serial-In-Parallel-Out) -// shift register (IE a very simple SR), and an LCD in 4-bit mode. -// Any such shift register should do (pref. 74LS family IC's for 2-wire). -// I used 74LS164, for the reason that's what I had at hand. -// -// Connection description: -// -// SR output: -// Bit #0 - N/C - not connected, used to hold a zero -// Bit #1 - N/C -// Bit #2 - connects to RS (Register Select) on the LCD -// Bits #3-6 - connects to LCD data inputs D4 - D7. -// Bit #7 - enables the LCD enable-puls (via the diode-resistor AND "gate") -// -// 2 or 3 Pins required from the Arduino for Data, Clock and (optional) Enable -// If not using Enable, the Data pin is used for the enable signal by defining -// the same pin for Enable as for Data. Data and Clock outputs/pins goes to -// the shiftregister. -// LCD RW-pin hardwired to LOW (only writing to LCD). -// Busy Flag (BF, data bit D7) is not read. -// -// Original project homepage: http://code.google.com/p/arduinoshiftreglcd/ -// -// -// History -// 2012.03.29 bperrybap - Added delays for faster fio shiftout (it got too fast) -// AVR needed delay. cmd/write delays are based on CPU speed so it works on pic32. -// Added code to support indicating two wire mode by using enable=data pin -// (documentation indicated this as working) -// Fixed incorrect use of 5x10 for default font - now matches original LQ library. -// can now eliminate enable pin in constructor for two wire mode. -// 2012.01.16 Florian Fida - faster digitalWrite/shiftOut -// 2011.10.29 fmalpartida - adaption of the library to the LCD class hierarchy. -// 2011.07.02 Fixed a minor flaw in setCursor function. No functional change, -// just a bit more memory efficient. -// Thanks to CapnBry (from google code and github) who noticed it. -// URL to his version of shiftregLCD: -// https://github.com/CapnBry/HeaterMeter/commit/c6beba1b46b092ab0b33bcbd0a30a201fd1f28c1 -// 2009.07.30 raron - minor corrections to the comments. -// Fixed timing to datasheet safe. Fixed keyword highlights. -// 2009.07.28 Mircho / raron - a new modification to the schematics, and a -// more streamlined interface -// 2009.07.27 Thanks to an excellent suggestion from mircho at the Arduino -// playgrond forum, the number of wires now required is only two! -// 2009.07.25 raron - Fixed comments. I really messed up the comments before -// posting this, so I had to fix it. -// Renamed a function, but no improvements or functional changes. -// 2009.07.23 Incorporated some proper initialization routines -// inspired (lets say copy-paste-tweaked) from LiquidCrystal -// library improvements from LadyAda. -// 2009.05.23 raron - first version, but based mostly (as in almost verbatim) -// on the "official" LiquidCrystal library. -// -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#include <stdio.h> -#include <string.h> -#include <inttypes.h> - -#if (ARDUINO < 100) -#include <WProgram.h> -#else -#include <Arduino.h> -#endif -#include "LiquidCrystal_SR.h" - -#include "FastIO.h" - - -// CONSTRUCTORS -// --------------------------------------------------------------------------- -// Assuming 1 line 8 pixel high font -LiquidCrystal_SR::LiquidCrystal_SR (uint8_t srdata, uint8_t srclock, - uint8_t enable ) -{ - init ( srdata, srclock, enable, 1, 0 ); -} - - -// PRIVATE METHODS -// --------------------------------------------------------------------------- - -// -// init -void LiquidCrystal_SR::init(uint8_t srdata, uint8_t srclock, uint8_t enable, - uint8_t lines, uint8_t font) -{ - // Initialise private variables - _two_wire = 0; - - _srDataRegister = fio_pinToOutputRegister(srdata); - _srDataBit = fio_pinToBit(srdata); - _srClockRegister = fio_pinToOutputRegister(srclock); - _srClockBit = fio_pinToBit(srclock); - - if ((enable == TWO_WIRE) || (enable == srdata)) - { - _two_wire = 1; - _srEnableRegister = _srDataRegister; - _srEnableBit = _srDataBit; - } - else - { - _srEnableRegister = fio_pinToOutputRegister(enable); - _srEnableBit = fio_pinToBit(enable); - } - - // Configure control pins as outputs - // ------------------------------------------------------------------------ - - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; -} - -// -// shiftIt -void LiquidCrystal_SR::shiftIt(uint8_t val) -{ - if (_two_wire) - { - // Clear to get Enable LOW - fio_shiftOut(_srDataRegister, _srDataBit, _srClockRegister, _srClockBit); - } - fio_shiftOut(_srDataRegister, _srDataBit, _srClockRegister, _srClockBit, val, MSBFIRST); - - // LCD ENABLE PULSE - // - // While this library is written with a shift register without an output - // latch in mind, it can work in 3-wire mode with a shiftregister with a - // latch. The shiftregister latch pin (STR, RCL or similar) is then - // connected to the LCD enable pin. The LCD is (very likely) slower - // to read the Enable pulse, and then reads the new contents of the SR. - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - fio_digitalWrite_HIGH(_srEnableRegister, _srEnableBit); - waitUsec (1); // enable pulse must be >450ns - fio_digitalWrite_SWITCHTO(_srEnableRegister, _srEnableBit, LOW); - } // end critical section -} - -// PUBLIC METHODS -// --------------------------------------------------------------------------- - - -/************ low level data pushing commands **********/ -// -// send -void LiquidCrystal_SR::send(uint8_t value, uint8_t mode) -{ - // Divide byte in two nibbles include the RS signal - // and format it for shiftregister output wiring to the LCD - // We are only interested in my COMMAND or DATA for myMode - uint8_t myMode = ( mode == DATA ) ? SR_RS_BIT : 0; // RS bit; LOW: command. HIGH: character. - - if ( mode != FOUR_BITS ) - { - shiftIt(myMode | SR_EN_BIT | ((value >> 1) & 0x78)); // upper nibble - } - - shiftIt(myMode | SR_EN_BIT | ((value << 3) & 0x78)); // lower nibble - /* - * Add some delay since this code is so fast it needs some added delay - * even on AVRs because the shiftout is shorter than the LCD command execution time. - */ -#if (F_CPU <= 16000000) - if(_two_wire) - delayMicroseconds ( 10 ); - else - delayMicroseconds ( 17 ); // 3 wire mode is faster so it must delay longer -#else - delayMicroseconds ( 37 ); // commands & data writes need > 37us to complete -#endif - -} - -// -// setBacklightPin -void LiquidCrystal_SR::setBacklightPin ( uint8_t pin, t_backlighPol pol ) -{ } - -// -// setBacklight -void LiquidCrystal_SR::setBacklight ( uint8_t mode ) -{ } -
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,176 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal_SR.h -// Connects an LCD using 2 or 3 pins from the Arduino, via an 8-bit -// ShiftRegister (SR from now on). -// -// @brief -// This is a port of the ShiftRegLCD library from raron and ported to the -// LCD library. -// -// The functionality provided by this class and its base class is identical -// to the original functionality of the Arduino LiquidCrystal library and can -// be used as such. -// -// Modified to work serially with the shiftOut() function, an 8-bit -// unlatched, no-tristate, unidirectional SIPO (Serial-In-Parallel-Out) -// shift register (IE a very simple SR), and an LCD in 4-bit mode. -// Any such shift register should do (pref. 74LS family IC's for 2-wire). -// I used 74LS164, for the reason that's what I had at hand. -// -// Connection description: -// -// SR output: -// Bit #0 - N/C - not connected, used to hold a zero -// Bit #1 - N/C -// Bit #2 - connects to RS (Register Select) on the LCD -// Bits #3-6 - connects to LCD data inputs D4 - D7. -// Bit #7 - enables the LCD enable-puls (via the diode-resistor AND "gate") -// -// 2 or 3 Pins required from the Arduino for Data, Clock and (optional) Enable -// If not using Enable, the Data pin will be used for the enable signal. -// 2 wire mode can be indicated by: -// - ommitting the enable pin in constructor -// - defining the same pin for Enable as for Data in constructor -// - by using the token TWO_WIRE for the enable pin. -// -// Data and Clock outputs/pins goes to the shiftregister. -// LCD RW-pin hardwired to LOW (only writing to LCD). -// Busy Flag (BF, data bit D7) is not read. -// -// Original project homepage: http://code.google.com/p/arduinoshiftreglcd/ -// -// -// History -// 2012.03.29 bperrybap - can now eliminate enable pin in constructor for two wire mode. -// 2011.10.29 fmalpartida - adaption of the library to the LCD class hierarchy. -// 2011.07.02 Fixed a minor flaw in setCursor function. No functional change, -// just a bit more memory efficient. -// Thanks to CapnBry (from google code and github) who noticed it. -// URL to his version of shiftregLCD: -// https://github.com/CapnBry/HeaterMeter/commit/c6beba1b46b092ab0b33bcbd0a30a201fd1f28c1 -// 2009.07.30 raron - minor corrections to the comments. -// Fixed timing to datasheet safe. Fixed keyword highlights. -// 2009.07.28 Mircho / raron - a new modification to the schematics, and a -// more streamlined interface -// 2009.07.27 Thanks to an excellent suggestion from mircho at the Arduiono -// playgrond forum, the number of wires now required is only two! -// 2009.07.25 raron - Fixed comments. I really messed up the comments before -// posting this, so I had to fix it. -// Renamed a function, but no improvements or functional changes. -// 2009.07.23 Incorporated some proper initialization routines -// inspired (lets say copy-paste-tweaked) from LiquidCrystal -// library improvements from LadyAda. -// 2009.05.23 raron - first version, but based mostly (as in almost verbatim) -// on the "official" LiquidCrystal library. -// -// -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#ifndef _LIQUIDCRYSTAL_SR_ -#define _LIQUIDCRYSTAL_SR_ - -#include <inttypes.h> -#include "LCD.h" -#include "FastIO.h" - - -// two-wire indicator constant -// --------------------------------------------------------------------------- -#define TWO_WIRE 204 -#define SR_RS_BIT 0x04 -#define SR_EN_BIT 0x80 - -class LiquidCrystal_SR : public LCD -{ -public: - /*! - @method - @abstract LCD SHIFT REGISTER constructors. - @discussion Defines the pin assignment that the LCD will have. - The constructor does not initialize the LCD. Assuming 1 line 8 pixel high - font. - - @param srdata[in] pin for shiftregister data line. - @param srclock[in] pin for shiftregister clock line. - @param enable[in] optional direct enable pin for the LCD - */ - LiquidCrystal_SR ( uint8_t srdata, uint8_t srclock, uint8_t enable=TWO_WIRE ); - - /*! - @function - @abstract Send a particular value to the LCD. - @discussion Sends a particular value to the LCD for writing to the LCD or - as an LCD command using the shift register. - - Users should never call this method. - - @param value[in] Value to send to the LCD. - @result mode LOW - write to the LCD CGRAM, HIGH - write a command to - the LCD. - */ - virtual void send(uint8_t value, uint8_t mode); - - - /*! - @function - @abstract Sets the pin to control the backlight. - @discussion Sets the pin in the device to control the backlight. - @warning Currently not supported - - @param mode: backlight mode (HIGH|LOW) - @param pol: backlight polarity - */ - void setBacklightPin ( uint8_t pin, t_backlighPol pol ); - - /*! - @function - @abstract Switch-on/off the LCD backlight. - @discussion Switch-on/off the LCD backlight. - The setBacklightPin has to be called before setting the backlight for - this method to work. @see setBacklightPin. - - @param mode: backlight mode (HIGH|LOW) - */ - void setBacklight ( uint8_t mode ); - -private: - - /*! - @method - @abstract Initializes the LCD pin allocation - @discussion Initializes the LCD pin allocation and configuration. - */ - void init ( uint8_t srdata, uint8_t srclock, uint8_t enable, uint8_t lines, - uint8_t font ); - - /*! - * @method - * @abstract takes care of shifting and the enable pulse - */ - void shiftIt (uint8_t val); - - uint8_t _enable_pin; // Enable Pin - uint8_t _two_wire; // two wire mode - - fio_register _srDataRegister; // Serial Data pin - fio_bit _srDataBit; - fio_register _srClockRegister; // Clock Pin - fio_bit _srClockBit; - fio_register _srEnableRegister; // Enable Pin - fio_bit _srEnableBit; - -}; - -#endif -
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR2W.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -// --------------------------------------------------------------------------- -// Created/Adapted by Bill Perry 2012-03-16 -// Copyright 2012 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal_SR2W.cpp -// Connects a hd44780 LCD using 2 pins from the Arduino, via an 8-bit -// ShiftRegister (SR2W from now on). -// -// @brief -// This is a port of the ShiftRegLCD library from raron and ported to the -// LCD library. -// -// -// See the corresponding SR2W header file for full details. -// -// History -// 2012.03.29 bperrybap - Fixed incorrect use of 5x10 for default font -// (now matches original LQ library) -// Fixed typo in SR2W mask define names -// changed default backlight state to on -// 2012.03.16 bperrybap - created/modified from SR sources to create SR2W -// @author B. Perry - bperrybap@opensource.billsworld.billandterrie.com -// --------------------------------------------------------------------------- - -#include "LiquidCrystal_SR2W.h" - -// CONSTRUCTORS -// --------------------------------------------------------------------------- -// Assuming 1 line 8 pixel high font -LiquidCrystal_SR2W::LiquidCrystal_SR2W (uint8_t srdata, uint8_t srclock, t_backlighPol blpol) -{ - init ( srdata, srclock, blpol, 1, 0 ); -} - - -// PRIVATE METHODS -// --------------------------------------------------------------------------- - -// -// init -void LiquidCrystal_SR2W::init(uint8_t srdata, uint8_t srclock, t_backlighPol blpol, uint8_t lines, uint8_t font) -{ - _srDataRegister = fio_pinToOutputRegister(srdata); - _srDataMask = fio_pinToBit(srdata); - _srClockRegister = fio_pinToOutputRegister(srclock); - _srClockMask = fio_pinToBit(srclock); - - _blPolarity = blpol; - - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - - backlight(); // set default backlight state to on -} - -// -// loadSR -void LiquidCrystal_SR2W::loadSR(uint8_t val) -{ - // Clear to keep Enable LOW while clocking in new bits - fio_shiftOut(_srDataRegister, _srDataMask, _srClockRegister, _srClockMask); - - - // clock out SR data byte - fio_shiftOut(_srDataRegister, _srDataMask, _srClockRegister, _srClockMask, val, MSBFIRST); - - - // strobe LCD enable which can now be toggled by the data line - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - fio_digitalWrite_HIGH(_srDataRegister, _srDataMask); - waitUsec (1); // enable pulse must be >450ns - fio_digitalWrite_SWITCHTO(_srDataRegister, _srDataMask, LOW); - } // end critical section -} - -// PUBLIC METHODS -// --------------------------------------------------------------------------- - - -/************ low level data pushing commands **********/ -// -// send -void LiquidCrystal_SR2W::send(uint8_t value, uint8_t mode) -{ - uint8_t myMode = ( mode == DATA ) ? SR2W_RS_MASK : 0; - - myMode = myMode | SR2W_EN_MASK | _blMask; - - if ( mode != FOUR_BITS ) - { - loadSR(myMode | ((value >> 1) & SR2W_DATA_MASK)); // upper nibble - } - - loadSR(myMode | ((value << 3) & SR2W_DATA_MASK)); // lower nibble - - /* - * Don't call waitUsec() - * do our own delay optmization since this code is so fast it needs some added delay - * even on slower AVRs. - */ -#if (F_CPU <= 16000000) - delayMicroseconds ( 10 ); // commands & data writes need > 37us to complete -#else - delayMicroseconds ( 37 ); // commands & data writes need > 37us to complete -#endif -} - -// -// setBacklight -void LiquidCrystal_SR2W::setBacklight ( uint8_t value ) -{ - // Check for polarity to configure mask accordingly - // ---------------------------------------------------------- - if ( ((_blPolarity == POSITIVE) && (value > 0)) || - ((_blPolarity == NEGATIVE ) && ( value == 0 )) ) - { - _blMask = SR2W_BL_MASK; - } - else - { - _blMask = 0; - } - - // send dummy data of blMask to set BL pin - // Note: loadSR() will strobe the data line trying to pulse EN - // but E will not strobe because the EN output bit is not set. - loadSR(_blMask); -}
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR2W.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -// --------------------------------------------------------------------------- -// Created/Adapted by Bill Perry 2012-03-16 -// Copyright 2012 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// @file LiquidCrystal_SR2W.h -// Connects a hd44780 LCD using 2 pins from the Arduino, via an 8-bit -// ShiftRegister (SR2W from now on). -// -// @brief -// This is the 2 wire shift register interface class for the LCD library -// -// The functionality provided by this class and its base class is a superset of -// the original functionality of the Arduino LiquidCrystal library and can -// be used as such. -// See the LCD class for a full description of the API functions available. -// -// It works with a 8-bit unlatched, no-tristate, unidirectional SIPO (Serial-In-Parallel-Out) -// shift register (IE a very simple SR), and an hd44780 LCD in 4-bit mode. -// Any such shift register should do (pref. 74LS family IC's for 2-wire). -// 74LS164 and 74HC595 have been exstensively tested. -// -// -// 2 Pins required from the Arduino: -// - Data/Enable -// - Clock -// The Data pin is also used to control the enable signal -// LCD RW-pin hardwired to LOW (only writing to LCD). -// Busy Flag (BF, data bit D7) is not read. -// -// Original project homepage: http://code.google.com/p/arduinoshiftreglcd/ -// -// Shift register bits -// Bit #0 - (cannot be used on 74HC595) -// Bit #1 - optional backlight control -// Bit #2 - connects to RS (Register Select) on the LCD -// Bit #3 - connects to LCD data inputs D4 -// Bit #4 - connects to LCD data inputs D5 -// Bit #5 - connects to LCD data inputs D6 -// Bit #6 - connects to LCD data inputs D7 -// Bit #7 - enables the LCD enable-puls (via the diode-resistor AND "gate") -// -// Wiring for a 74LS164 -// --------------------- -// 1k/4.7k -// +--------[ Resistor ]--------+---(LCD Enable) -// | | -// | 74LS164 (VCC) | -// | +----u----+ | _V_ diode -// (data pin)---+---+--1-|A VCC|-14-+ | -// | | | | -// +--2-|B Q7|-13------+ -// 3-|Q0 Q6|-12--(LCD D7) -// (BL Circuit)--------4-|Q1 Q5|-11--(LCD D6) -// (LCD RS)------------5-|Q2 Q4|-10--(LCD D5) -// (LCD D4)------------6-|Q3 /MR|--9--(VCC) -// +-7-|GND CP|--8--(clock pin) -// | +---------+ -// | 0.1uf -// (gnd)-----||----(vcc) -// -// Wiring for a 74HC595 -// -------------------- -// NOTE: the 74HC595 is a latching shift register. In order to get it to operate -// in a "non latching" mode, RCLK and SCLK are tied together. The side effect of this -// is that the latched output is one clock behind behind the internal shift register bits. -// To compensate for this the wiring is offset by one bit position lower. -// For example, while the backlight is hooked to Q0 it is still using bit 1 of -// of the shift register because the outputs are 1 clock behind the real internal shift -// register. -// -// 74HC595 (VCC) -// +----u----+ | +-----------------------(BL circuit) -// (LCD RS)------------1-|Q1 VCC|-16-+ | +--------------------(data pin) -// (LCD D4)------------2-|Q2 Q0|-15----+ | 1k/4.7k -// (LCD D5)------------3-|Q3 SER|-14-------+---[ Resistor ]--+--(LCD Enable) -// (LCD D6)------------4-|Q4 /OE|-13--(gnd) | -// (LCD D7)------------5-|Q5 RCLK|-12-------+ | -// | | | | -// +------6-|Q6 SCLK|-11-------+--(clock pin) | -// | 7-|Q7 /MR|-10--(VCC) | -// | +-8-|GND Q6'|--9 | -// | | +---------+ diode _V_ -// | | 0.1uf | -// | (gnd)-----||----(vcc) | -// +-----------------------------------------------+ -// -// -// Backlight Control circuit -// ------------------------- -// Because the shift resiter is not latching the outputs, the backlight circuitry -// will "see" the output bits as they are shifted into the shift register which -// can cause the backlight to flicker rather than remain constantly on/off. -// The circuit below slows down the transitions to the transistor to remove -// the visible flicker. When the BL input is HIGH the LCD backlight will turn on. -// -// (value depends on LCD, 100ohm is usually safe) -// (LCD BL anode)---[ resistor ]---(vcc) -// -// (LCD BL cathode)-------------------------------+ -// | -// D -// | -// (BL input)----[ 4.7k Resistor ]----+-------G-|-< (2N7000 FET) -// | | -// (0.1uf) = S -// | | -// (gnd) (gnd) -// -// -// -// -// History -// 2012.03.16 bperrybap - creation/adaption from SR header to create SR2W header. -// Fixed typo in SR2W mask define names -// @author B. Perry - bperrybap@opensource.billsworld.billandterrie.com -// -------------------------------------------------------------------------------- -#ifndef _LIQUIDCRYSTAL_SR2W_ -#define _LIQUIDCRYSTAL_SR2W_ - -#include <inttypes.h> -#include "LCD.h" -#include "FastIO.h" - - -// two-wire SR output bit constants -// --------------------------------------------------------------------------- - -#define SR2W_BL_MASK 0x02 -#define SR2W_RS_MASK 0x04 -#define SR2W_DATA_MASK 0x78 // data bits are hard coded to be SR bits 6,5,4,3 -#define SR2W_EN_MASK 0x80 // cannot ever be changed - -class LiquidCrystal_SR2W : public LCD -{ -public: - /*! - @method - @abstract LCD 2 wire SHIFT REGISTER constructor. - @discussion Defines the pin assignments that connect to the shift register. - The constructor does not initialize the LCD. Assuming 1 line 8 pixel high - font. - - @param srdata[in] Arduino pin for shift register data line. - @param srclock[in] Arduino pin for shift register clock line. - @param blpol[in] optional backlight polarity (default = POSITIVE) - */ - LiquidCrystal_SR2W (uint8_t srdata, uint8_t srclock, t_backlighPol blpol = POSITIVE); - - /*! - @function - @abstract Send a particular value to the LCD. - @discussion Sends a particular value to the LCD for writing to the LCD or - as an LCD command using the shift register. - - Users should never call this method. - - @param value[in] Value to send to the LCD. - @param mode[in] DATA=8bit data, COMMAND=8bit cmd, FOUR_BITS=4bit cmd - the LCD. - */ - virtual void send(uint8_t value, uint8_t mode); - - - /*! - @function - @abstract Switch-on/off the LCD backlight. - @discussion Switch-on/off the LCD backlight. - The setBacklightPin has to be called before setting the backlight for - this method to work. @see setBacklightPin. - - @param mode[in] backlight mode (0 off, non-zero on) - */ - void setBacklight ( uint8_t mode ); - -private: - - /*! - @method - @abstract Initializes the LCD pin allocation - @discussion Initializes the LCD pin allocation and configuration. - */ - void init ( uint8_t srdata, uint8_t srclock, t_backlighPol blpol, uint8_t lines, uint8_t font ); - - /*! - * @method - * @abstract takes care of shifting and the enable pulse - */ - void loadSR (uint8_t val); - - fio_register _srDataRegister; // Serial Data pin - fio_bit _srDataMask; - fio_register _srClockRegister; // Clock Pin - fio_bit _srClockMask; - - uint8_t _blPolarity; - uint8_t _blMask; -}; -#endif
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR3W.cpp Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 7.3.2012. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal_SRG.h -// This file implements a basic liquid crystal library that comes as standard -// in the Arduino SDK but using a generic SHIFT REGISTER extension board. -// -// @brief -// This is a basic implementation of the LiquidCrystal library of the -// Arduino SDK. The original library has been reworked in such a way that -// this class implements the all methods to command an LCD based -// on the Hitachi HD44780 and compatible chipsets using a 3 wire latching -// shift register. While it has been tested with a 74HC595N shift register -// it should also work with other latching shift registers such as the MC14094 -// and the HEF4094 -// -// This particular driver has been created as generic as possible to enable -// users to configure and connect their LCDs using just 3 digital IOs from the -// AVR or Arduino, and connect the LCD to the outputs of the shiftregister -// in any configuration. The library is configured by passing the IO pins -// that control the strobe, data and clock of the shift register and a map -// of how the shiftregister is connected to the LCD. -// -// -// +--------------------------------------------+ -// | MCU | -// | IO1 IO2 IO3 | -// +----+-------------+-------------+-----------+ -// | | | -// | | | -// +----+-------------+-------------+-----------+ -// | Strobe Data Clock | -// | 8-bit shift/latch register | 74HC595N -// | Qa0 Qb1 Qc2 Qd3 Qe4 Qf5 Qg6 Qh7 | -// +----+----+----+----+----+----+----+----+----+ -// | | | | | | | -// |11 |12 |13 |14 |6 |5 |4 (LCD pins) -// +----+----+----+----+----+----+----+----+----+ -// | DB4 DB5 DB6 DB7 E Rw RS | -// | LCD Module | -// -// NOTE: Rw is not used by the driver so it can be connected to GND. -// -// The functionality provided by this class and its base class is identical -// to the original functionality of the Arduino LiquidCrystal library. -// -// -// History -// 2012.03.29 bperrybap - fixed constructors not properly using Rs -// Fixed incorrect use of 5x10 for default font -// - now matches original LQ library. -// moved delay to send() so it is per cmd/write vs shiftout() -// NOTE: delay is on hairy edge of working when FAST_MODE is on. -// because of waitUsec(). -// There is margin at 16Mhz AVR but might fail on 20Mhz AVRs. -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -// flags for backlight control -#include <stdio.h> -#include <string.h> -#include <inttypes.h> - -#if (ARDUINO < 100) -#include <WProgram.h> -#else -#include <Arduino.h> -#endif -#include "LiquidCrystal_SR3W.h" - -#include "FastIO.h" - -/*! - @defined - @abstract LCD_NOBACKLIGHT - @discussion No BACKLIGHT MASK - */ -#define LCD_NOBACKLIGHT 0x00 - -/*! - @defined - @abstract LCD_BACKLIGHT - @discussion BACKLIGHT MASK used when backlight is on - */ -#define LCD_BACKLIGHT 0xFF - - -// Default library configuration parameters used by class constructor with -// only the I2C address field. -// --------------------------------------------------------------------------- -/*! - @defined - @abstract Enable bit of the LCD - @discussion Defines the IO of the expander connected to the LCD's Enable - */ -#define EN 4 // Enable bit - -/*! - @defined - @abstract Read/Write bit of the LCD - @discussion Defines the IO of the expander connected to the LCD's Rw pin - */ -#define RW 5 // Read/Write bit - -/*! - @defined - @abstract Register bit of the LCD - @discussion Defines the IO of the expander connected to the LCD's Register select pin - */ -#define RS 6 // Register select bit - -/*! - @defined - @abstract LCD dataline allocation this library only supports 4 bit LCD control - mode. - @discussion D4, D5, D6, D7 LCD data lines pin mapping of the extender module - */ -#define D4 0 -#define D5 1 -#define D6 2 -#define D7 3 - - - -LiquidCrystal_SR3W::LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe) -{ - init( data, clk, strobe, RS, RW, EN, D4, D5, D6, D7 ); -} - -LiquidCrystal_SR3W::LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, - uint8_t backlighPin, t_backlighPol pol) -{ - init( data, clk, strobe, RS, RW, EN, D4, D5, D6, D7 ); - setBacklightPin(backlighPin, pol); -} - -LiquidCrystal_SR3W::LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, - uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ) -{ - init( data, clk, strobe, Rs, Rw, En, d4, d5, d6, d7 ); -} - -LiquidCrystal_SR3W::LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, - uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t backlighPin, t_backlighPol pol) -{ - init( data, clk, strobe, Rs, Rw, En, d4, d5, d6, d7 ); - setBacklightPin(backlighPin, pol); -} - - -void LiquidCrystal_SR3W::send(uint8_t value, uint8_t mode) -{ - - if ( mode != FOUR_BITS ) - { - write4bits( (value >> 4), mode ); // upper nibble - } - write4bits( (value & 0x0F), mode); // lower nibble - - -#if (F_CPU <= 16000000) - // No need to use the delay routines on AVR since the time taken to write - // on AVR with SR pin mapping even with fio is longer than LCD command execution. - waitUsec(37); //goes away on AVRs -#else - delayMicroseconds ( 37 ); // commands & data writes need > 37us to complete -#endif - -} - - -void LiquidCrystal_SR3W::setBacklightPin ( uint8_t value, t_backlighPol pol = POSITIVE ) -{ - _backlightPinMask = ( 1 << value ); - _backlightStsMask = LCD_NOBACKLIGHT; - _polarity = pol; - setBacklight (BACKLIGHT_OFF); // Set backlight to off as initial setup -} - -void LiquidCrystal_SR3W::setBacklight ( uint8_t value ) -{ - // Check if backlight is available - // ---------------------------------------------------- - if ( _backlightPinMask != 0x0 ) - { - // Check for polarity to configure mask accordingly - // ---------------------------------------------------------- - if (((_polarity == POSITIVE) && (value > 0)) || - ((_polarity == NEGATIVE ) && ( value == 0 ))) - { - _backlightStsMask = _backlightPinMask & LCD_BACKLIGHT; - } - else - { - _backlightStsMask = _backlightPinMask & LCD_NOBACKLIGHT; - } - loadSR( _backlightStsMask ); - } -} - - -// PRIVATE METHODS -// ----------------------------------------------------------------------------- - -int LiquidCrystal_SR3W::init(uint8_t data, uint8_t clk, uint8_t strobe, - uint8_t Rs, uint8_t Rw, uint8_t En, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) -{ - _data = fio_pinToBit(data); - _clk = fio_pinToBit(clk); - _strobe = fio_pinToBit(strobe); - _data_reg = fio_pinToOutputRegister(data); - _clk_reg = fio_pinToOutputRegister(clk); - _strobe_reg = fio_pinToOutputRegister(strobe); - - // LCD pin mapping - _backlightPinMask = 0; - _backlightStsMask = LCD_NOBACKLIGHT; - _polarity = POSITIVE; - - _En = ( 1 << En ); - _Rw = ( 1 << Rw ); - _Rs = ( 1 << Rs ); - - // Initialise pin mapping - _data_pins[0] = ( 1 << d4 ); - _data_pins[1] = ( 1 << d5 ); - _data_pins[2] = ( 1 << d6 ); - _data_pins[3] = ( 1 << d7 ); - - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - - return (1); -} - -void LiquidCrystal_SR3W::write4bits(uint8_t value, uint8_t mode) -{ - uint8_t pinMapValue = 0; - - // Map the value to LCD pin mapping - // -------------------------------- - for ( uint8_t i = 0; i < 4; i++ ) - { - if ( ( value & 0x1 ) == 1 ) - { - pinMapValue |= _data_pins[i]; - } - value = ( value >> 1 ); - } - - // Is it a command or data - // ----------------------- - mode = ( mode == DATA ) ? _Rs : 0; - - pinMapValue |= mode | _backlightStsMask; - loadSR ( pinMapValue | _En ); // Send with enable high - loadSR ( pinMapValue); // Send with enable low -} - - -void LiquidCrystal_SR3W::loadSR(uint8_t value) -{ - // Load the shift register with information - fio_shiftOut(_data_reg, _data, _clk_reg, _clk, value, MSBFIRST); - - // Strobe the data into the latch - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - fio_digitalWrite_HIGH(_strobe_reg, _strobe); - fio_digitalWrite_SWITCHTO(_strobe_reg, _strobe, LOW); - } -}
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal_SR3W.h Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 7.3.2012. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file LiquidCrystal_SR3W.h -// This file implements a basic liquid crystal library that comes as standard -// in the Arduino SDK but using a generic SHIFT REGISTER extension board. -// -// @brief -// This is a basic implementation of the LiquidCrystal library of the -// Arduino SDK. The original library has been reworked in such a way that -// this class implements the all methods to command an LCD based -// on the Hitachi HD44780 and compatible chipsets using a 3 wire latching -// shift register. While it has been tested with a 74HC595N shift register -// it should also work with other latching shift registers such as the MC14094 -// and the HEF4094 -// -// This particular driver has been created as generic as possible to enable -// users to configure and connect their LCDs using just 3 digital IOs from the -// AVR or Arduino, and connect the LCD to the outputs of the shiftregister -// in any configuration. The library is configured by passing the IO pins -// that control the strobe, data and clock of the shift register and a map -// of how the shiftregister is connected to the LCD. -// -// -// +--------------------------------------------+ -// | MCU | -// | IO1 IO2 IO3 | -// +----+-------------+-------------+-----------+ -// | | | -// | | | -// +----+-------------+-------------+-----------+ -// | Strobe Data Clock | -// | 8-bit shift/latch register | 74HC595N -// | Qa0 Qb1 Qc2 Qd3 Qe4 Qf5 Qg6 Qh7 | -// +----+----+----+----+----+----+----+----+----+ -// | | | | | | | -// |11 |12 |13 |14 |6 |5 |4 (LCD pins) -// +----+----+----+----+----+----+----+----+----+ -// | DB4 DB5 DB6 DB7 E Rw RS | -// | LCD Module | -// -// NOTE: Rw is not used by the driver so it can be connected to GND. -// -// The functionality provided by this class and its base class is identical -// to the original functionality of the Arduino LiquidCrystal library. -// -// -// @author F. Malpartida - fmalpartida@gmail.com -// --------------------------------------------------------------------------- -#ifndef _LIQUIDCRYSTAL_SR3W_H_ -#define _LIQUIDCRYSTAL_SR3W_H_ - -#include <inttypes.h> -#include "LCD.h" -#include "FastIO.h" - - -class LiquidCrystal_SR3W : public LCD -{ -public: - - /*! - @method - @abstract Class constructor. - @discussion Initializes class variables and defines the IO driving the - shift register. The constructor does not initialize the LCD. - Default configuration: - Shift register LCD - QA - 0 DB4 - QB - 1 DB5 - QC - 2 DB6 - QD - 3 DB7 - QE - 4 E - QF - 5 - QG - 6 Rs - GND Rw - - @param strobe[in] digital IO connected to shiftregister strobe pin. - @param data[in] digital IO connected to the shiftregister data pin. - @param clk[in] digital IO connected to the shiftregister clock pin. - */ - LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe); - // Constructor with backlight control - LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, - uint8_t backlighPin, t_backlighPol pol); - - /*! - @method - @abstract Class constructor. - @discussion Initializes class variables and defines the control lines of - the LCD and the shiftregister. The constructor does not initialize the LCD. - - @param strobe[in] digital IO connected to shiftregister strobe pin. - @param data[in] digital IO connected to shiftregister data pin. - @param clk[in] digital IO connected to shiftregister clock pin. - @param En[in] LCD En (Enable) pin connected to SR output pin. - @param Rw[in] LCD Rw (Read/write) pin connected to SR output pin. - @param Rs[in] LCD Rs (Reg Select) pin connected to SR output pin. - @param d4[in] LCD data 4 pin map to the SR output pin. - @param d5[in] LCD data 5 pin map to the SR output pin. - @param d6[in] LCD data 6 pin map to the SR output pin. - @param d7[in] LCD data 7 pin map to the SR output pin. - */ - LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, - uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ); - // Constructor with backlight control - LiquidCrystal_SR3W( uint8_t data, uint8_t clk, uint8_t strobe, - uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t backlighPin, t_backlighPol pol); - - /*! - @function - @abstract Send a particular value to the LCD. - @discussion Sends a particular value to the LCD for writing to the LCD or - as an LCD command. - - Users should never call this method. - - @param value[in] Value to send to the LCD. - @param mode[in] DATA - write to the LCD CGRAM, COMMAND - write a - command to the LCD. - */ - virtual void send(uint8_t value, uint8_t mode); - - /*! - @function - @abstract Sets the pin to control the backlight. - @discussion Sets the pin in the device to control the backlight. This device - doesn't support dimming backlight capability. - - @param 0: backlight off, 1..255: backlight on. - */ - void setBacklightPin ( uint8_t value, t_backlighPol pol ); - - /*! - @function - @abstract Switch-on/off the LCD backlight. - @discussion Switch-on/off the LCD backlight. - The setBacklightPin has to be called before setting the backlight for - this method to work. @see setBacklightPin. - - @param value: backlight mode (HIGH|LOW) - */ - void setBacklight ( uint8_t value ); - -private: - - /*! - @method - @abstract Initializes the LCD class - @discussion Initializes the LCD class and IO expansion module. - */ - int init(uint8_t data, uint8_t clk, uint8_t strobe, - uint8_t Rs, uint8_t Rw, uint8_t En, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - - /*! - @method - @abstract Writes an 4 bit value to the LCD. - @discussion Writes 4 bits (the least significant) to the LCD control data lines. - @param value[in] Value to write to the LCD - @param more[in] Value to distinguish between command and data. - COMMAND == command, DATA == data. - */ - void write4bits(uint8_t value, uint8_t mode); - - /*! - @function - @abstract load into the shift register a byte - @discussion loads into the shift register a byte - @param value[in]: value to be loaded into the shiftregister. - */ - void loadSR(uint8_t value); - - - fio_bit _strobe; // shift register strobe pin - fio_register _strobe_reg; // SR strobe pin MCU register - fio_bit _data; // shift register data pin - fio_register _data_reg; // SR data pin MCU register - fio_bit _clk; // shift register clock pin - fio_register _clk_reg; // SR clock pin MCU register - uint8_t _En; // LCD expander word for enable pin - uint8_t _Rw; // LCD expander word for R/W pin - uint8_t _Rs; // LCD expander word for Register Select pin - uint8_t _data_pins[4]; // LCD data lines - uint8_t _backlightPinMask; // Backlight IO pin mask - uint8_t _backlightStsMask; // Backlight status mask - -}; - -#endif -
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/HelloWorld_4bit/HelloWorld_4bit.pde Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -#include <Wire.h> -#include <LiquidCrystal.h> - - -#define CONTRAST_PIN 9 -#define BACKLIGHT_PIN 7 -#define CONTRAST 110 -LiquidCrystal lcd(12, 11, 5, 4, 3, 2, BACKLIGH_PIN, POSITIVE ); - - -// Creat a set of new characters -byte smiley[8] = { - 0b00000, - 0b00000, - 0b01010, - 0b00000, - 0b00000, - 0b10001, - 0b01110, - 0b00000 -}; - -byte armsUp[8] = { - 0b00100, - 0b01010, - 0b00100, - 0b10101, - 0b01110, - 0b00100, - 0b00100, - 0b01010 -}; - -byte frownie[8] = { - 0b00000, - 0b00000, - 0b01010, - 0b00000, - 0b00000, - 0b00000, - 0b01110, - 0b10001 -}; - -void setup() -{ - Serial.begin ( 57600 ); - - // Switch on the backlight and LCD contrast levels - pinMode(CONTRAST_PIN, OUTPUT); - analogWrite ( CONTRAST_PIN, CONTRAST ); - - //lcd.setBacklightPin ( BACKLIGHT_PIN, POSITIVE ); - //lcd.setBacklight ( HIGH ); - lcd.backlight(); - - lcd.begin(16,2); // initialize the lcd - - lcd.createChar (0, smiley); // load character to the LCD - lcd.createChar (1, armsUp); // load character to the LCD - lcd.createChar (2, frownie); // load character to the LCD - - lcd.home (); // go home - lcd.print("Hello, ARDUINO "); - lcd.setCursor ( 0, 1 ); // go to the next line - lcd.print (" FORUM - fm "); -} - -void loop() -{ - // Do a little animation by writing to the same location - lcd.setCursor ( 14, 1 ); - lcd.print (char(2)); - delay (200); - lcd.setCursor ( 14, 1 ); - lcd.print ( char(0)); - delay (200); -}
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/HelloWorld_SR/HelloWorld_SR.pde Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#include <Wire.h> -#include <LiquidCrystal_SR.h> - -LiquidCrystal_SR lcd(8,7,TWO_WIRE); -// | | -// | \-- Clock Pin -// \---- Data/Enable Pin - -// Creat a set of new characters -byte armsUp[8] = {0b00100,0b01010,0b00100,0b10101,0b01110,0b00100,0b00100,0b01010}; -byte armsDown[8] = {0b00100,0b01010,0b00100,0b00100,0b01110,0b10101,0b00100,0b01010}; - -void setup(){ - - lcd.begin(16,2); // initialize the lcd - - lcd.createChar (0, armsUp); // load character to the LCD - lcd.createChar (1, armsDown); // load character to the LCD - - lcd.home (); // go home - lcd.print("LiquidCrystal_SR"); -} - -void loop(){ - // Do a little animation - for(int i = 0; i <= 15; i++) showHappyGuy(i); - for(int i = 15; i >= 0; i--) showHappyGuy(i); -} - -void showHappyGuy(int pos){ - lcd.setCursor ( pos, 1 ); // go to position - lcd.print(char(random(0,2))); // show one of the two custom characters - delay(150); // wait so it can be seen - lcd.setCursor ( pos, 1 ); // go to position again - lcd.print(" "); // delete character -} \ No newline at end of file
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/HelloWorld_i2c/HelloWorld_i2c.pde Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -#include <Wire.h> -#include <LiquidCrystal_I2C.h> - - - -#define BACKLIGHT_PIN 13 - -LiquidCrystal_I2C lcd(0x38); // Set the LCD I2C address - -//LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address - - -// Creat a set of new characters -const uint8_t charBitmap[][8] = { - { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 }, - { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 }, - { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 }, - { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 }, - { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 }, - { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 }, - { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 }, - { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 } - -}; - -void setup() -{ - int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0])); - - // Switch on the backlight - pinMode ( BACKLIGHT_PIN, OUTPUT ); - digitalWrite ( BACKLIGHT_PIN, HIGH ); - - lcd.begin(16,2); // initialize the lcd - - for ( int i = 0; i < charBitmapSize; i++ ) - { - lcd.createChar ( i, (uint8_t *)charBitmap[i] ); - } - - lcd.home (); // go home - lcd.print("Hello, ARDUINO "); - lcd.setCursor ( 0, 1 ); // go to the next line - lcd.print (" FORUM - fm "); - delay ( 1000 ); -} - -void loop() -{ - lcd.home (); - // Do a little animation by writing to the same location - for ( int i = 0; i < 2; i++ ) - { - for ( int j = 0; j < 16; j++ ) - { - lcd.print (char(random(7))); - } - lcd.setCursor ( 0, 1 ); - } - delay (200); -}
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/LCDiSpeed/LCDiSpeed.pde Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,274 +0,0 @@ -static char dummyvar; // dummy declaration for STUPID IDE!!!! -/*---------------------------------------------------------------------------- - * vi:ts=4 - * - * LCDiSpeed - LCD Interface Speed - * - * Created by Bill Perry 2012-03-16 - * Copyright 2012 - Under creative commons license 3.0: - * Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) - * license page: http://creativecommons.org/licenses/by-nc-sa/3.0/ - * - * Sketch to measure and report the speed of the interface to the LCD and - * speed of updating the LCD. - * - * It runs a Frames/Sec (FPS) test which writes a "frame" of each digit 0-9 to - * the display. - * A "frame" is a full display of characters. - * It is created by positioning the cursor to the begining of each row - * and then writing a character to every position on the row, until the - * entire display is filled. - * The FPS test does a frame of 9's then 8's, .... down to 0's - * On fast interfaces it will not normally be seen. - * - * The sketch will then calculate & report transfer speeds and - * LCD update rates to the LCD display. - * - * Reported Information: - * - Single byte transfer speed (ByteXfer) - * This is the time it takes for a single character to be sent from - * the sketch to the LCD display. - * - * - Frame/Sec (FPS) - * This is the number of times the full display can be updated - * in one second. - * - * - Frame Time (Ftime) - * This is the amount of time it takes to update the full LCD display. - * - * - * The sketch will also report "independent" FPS and Ftime values. - * These are timing values that are independent of the size of the LCD under test. - * Currently they represent the timing for a 16x2 LCD - * The value of always having numbers for a 16x2 display - * is that these numbers can be compared to each other since they are - * independent of the size of the actual LCD display that is running the test. - * - * All times & rates are measured and calculeted from what a sketch "sees" - * using the LiquidCrystal API. - * It includes any/all s/w overhead including the time to go through the - * Arduino Print class and LCD library. - * The actual low level hardware times are obviously lower. - * - * History - * 2012.03.15 bperrybap - Original creation - * - * @author Bill Perry - bperrybap@opensource.billsworld.billandterrie.com - *---------------------------------------------------------------------------- - -/* - * Define your LCD size - */ -#define LCD_COLS 16 -#define LCD_ROWS 2 - -/* - * Pick your interface. - */ - -//#define LCDIF_4BIT -//#define LCDIF_I2C -//#define LCDIF_SR2W -//#define LCDIF_SR_2W // SR in 2 wire mode -//#define LCDIF_SR_3W // SR in 3 wire mode -#define LCDIF_SR3W -//#define LCDIF_SR1W - - -/* - * Options - */ - -#define FPS_iter 1 // number of iterations to repeat each "frame" within the test - // (current frame test is 10 full display frames, 1 for each digits 0-9) - // FPS_iter like 100 will allow the frames to be seen - // Note: the only reason other than visual to make this larger than 1 - // might be to compensate for Async serial buffering should a serial interface be tested - // even with 1 iteration, 340 bytes are written for a 16x2 display - // bytes written = FPS_iter * ((LCD_ROWS * LCD_COLS) + LCD_ROWS) * 10 - -#define iLCD // turn on code to calculate speed of "independent" sized display -#define iLCD_ROWS 2 // independent FPS row size -#define iLCD_COLS 16 // independent FPS col size - - -#define DELAY_TIME 3500 // delay time to see information on lcd - -#if defined(LCDIF_4BIT) - -// Include the Liquid Crystal library code: -#include <LiquidCrystal.h> - -// initialize the library with the numbers of the interface pins -// lcd(RS, E, d4, d5, d6, d7, bl, polarity) -#ifdef BACKLIGHT_ON -LiquidCrystal lcd( 8, 9, 4, 5, 6, 7, 10, POSITIVE); // new constructor with backlight support -#else -LiquidCrystal lcd( 8, 9, 4, 5, 6, 7); // old style constructor w/o backlight (to test old library) -#endif - -#elif defined(LCDIF_I2C) -#include <Wire.h> -#include <LiquidCrystal_I2C.h> - -LiquidCrystal_I2C lcd(0x38); // Set the LCD I2C address - - -#elif defined(LCDIF_SR3W) -#include <LiquidCrystal_SR3W.h> - // d,clk,strb, en,rw,rs,d4,d5,d6,d7,bl,blpol -//LiquidCrystal_SR3W lcd (2, 3, 4, 6, 7, 1, 2, 3, 4, 5, 0, POSITIVE); -LiquidCrystal_SR3W lcd(3, 2, 4); - -#elif defined(LCDIF_SR2W) - -#include <LiquidCrystal_SR2W.h> - // d, clk, (blPolarity optional, defaults to POSITIVE) -LiquidCrystal_SR2W lcd (2, 3); - -#elif defined(LCDIF_SR1W) - -#include <LiquidCrystal_SR1W.h> -LiquidCrystal_SR1W lcd (2); - -#elif defined(LCDIF_SR_2W) - -#include <LiquidCrystal_SR.h> - // d, clk -LiquidCrystal_SR lcd (2, 3); - -#elif defined(LCDIF_SR_3W) - -#include <LiquidCrystal_SR.h> - // d,clk,strb -LiquidCrystal_SR lcd (2, 3, 4); - -#endif - -void setup() -{ - // set up the LCD's number of columns and rows: - lcd.begin(LCD_COLS, LCD_ROWS); - -#ifdef BACKLIGHT_ON - lcd.backlight(); // make sure backlight is on with new library -#endif -} - -void loop() -{ -unsigned long etime; -char buf[8]; - - lcd.clear(); - - - /* - * Time an FPS test - */ - - etime = timeFPS(FPS_iter, LCD_COLS, LCD_ROWS); - - /* - * show the average single byte xfer time during the FPS test - */ - showByteXfer(etime); - - /* - * show FPS rate and Frame update time for this display - */ - - sprintf(buf, "%dx%d", LCD_COLS, LCD_ROWS); - showFPS(etime, buf); - -#ifdef iLCD - /* - * calculate Independent FPS and Frame update time - * (rate & time for a "standard" display - default of 16x2) - * This is simply a matter of scaling the time based on the - * ratio of the display sizes. - */ - - etime = etime *iLCD_ROWS * iLCD_COLS / LCD_ROWS / LCD_COLS; - - /* - * show independent FPS rate & Frame update time - */ - sprintf(buf, "%dx%d", iLCD_COLS, iLCD_ROWS); - showFPS(etime, buf); -#endif - -} - -unsigned long timeFPS(uint8_t iter, uint8_t cols, uint8_t rows) -{ -char c; -unsigned long stime, etime; - - stime = micros(); - for(c = '9'; c >= '0'; c--) // do not change this unless you change the FPS/ByteXfer calcuations as well - { - for(uint8_t i = 0; i < iter; i++) - { - for(uint8_t row = 0; row < rows; row++) - { - lcd.setCursor(0, row); - for(uint8_t col = 0; col< cols;col++) - { - lcd.write(c); - } - } - } - } - etime = micros(); - return((etime-stime)); -} -void showFPS(unsigned long etime, const char *type) -{ -float fps; - - - /* - * calculate Frame update time and FPS rate - * The 10.0 is for the 10 frames done per iteration - * one for each digit 0-9 - */ - - fps = (10.0 * FPS_iter) * 1000000.0/(etime); - - - lcd.clear(); - lcd.print(type); - lcd.print("FPS: "); - lcd.print(fps); - - if(LCD_ROWS > 1) - { - lcd.setCursor(0,1); - } - else - { - delay(DELAY_TIME); - lcd.clear(); - } - lcd.print("Ftime: "); - lcd.print((etime)/10.0/FPS_iter/1000); - lcd.print("ms"); - - delay(DELAY_TIME); -} -void showByteXfer(unsigned long etime) -{ - lcd.clear(); - lcd.print("ByteXfer: "); - /* - * Calculate average byte xfer time from time of FPS test - * This takes into consideration the set cursor position commands which - * are single byte commands and take the same amount of time as a data byte write. - * The final result is rounded up to an integer. - */ - lcd.print((int) (etime / (FPS_iter * (10.0 * (LCD_COLS * LCD_ROWS + LCD_ROWS)))+0.5)); - lcd.print("uS"); - - delay(DELAY_TIME); -}
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/LCDiSpeed/LCDiSpeed.txt Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -16Mhz AVR -Interface ByteXfer 16x2FPS Ftime ----------------------------------------------- -4BIT 338uS 86.92 11.51ms (orignal Liquid Crystal) -4BIT 98uS 298.58 3.35ms -SR2W 76uS 388.62 2.57ms -SR_2W 72uS 406.90 2.46ms -SR_3W 61uS 480.03 2.08ms -SR3W 102uS 287.92 3.47ms - - -80Mhz Pic32 (ChipKit Uno32) -Interface ByteXfer 16x2FPS Ftime ----------------------------------------------- -4BIT 232uS 126.73 7.89ms (orignal mpide Liquid Crystal) -4BIT 57uS 517.41 1.93ms -SR2W 53uS 557.35 1.79ms -SR_2W 53uS 554.66 1.80ms -SR_3W 50uS 591.40 1.69ms -SR3W 56uS 524.91 1.91ms
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/SerialDisplay/SerialDisplay.pde Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Displays text sent over the serial port (e.g. from the Serial Monitor) on - * an attached LCD. - */ -#include <Wire.h> -#include <LiquidCrystal_I2C.h> - -#define BACKLIGHT_PIN 13 - -LiquidCrystal_I2C lcd(0x38); // set the LCD address to 0x38 - -void setup() -{ - pinMode ( BACKLIGHT_PIN, OUTPUT ); - lcd.begin (16,2); - digitalWrite ( BACKLIGHT_PIN, HIGH ); - - Serial.begin(57600); -} - -void loop() -{ - // when characters arrive over the serial port... - if (Serial.available()) - { - // wait a bit for the entire message to arrive - delay(100); - // clear the screen - lcd.clear(); - // read all the available characters - while (Serial.available() > 0) - { - // display each character to the LCD - lcd.write(Serial.read()); - } - } -}
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/i2cLCDextraIO/i2cLCDextraIO.pde Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,246 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 1/1/12. -// Copyright 2011 - Under creative commons license: -// Attribution-NonCommercial-ShareAlike CC BY-NC-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file i2CLCDextraIO.pde -// Temperature logging to demonstrate the I2CLCDextraIO library. -// -// @brief This application is a demostration file for the I2CLCDextraIO library -// that reads a temperature from the internal ATMEGA328p temperature sensor -// and displays it on the LCD. The application also demonstrates some of the -// methods of the library, such as loading custom characters to the LCD, -// moving around the LCD, and writing to it. -// -// @author F. Malpartida -// --------------------------------------------------------------------------- -#include <Wire.h> -#include <LCD.h> - -#define _LCD_I2C_ - -#ifdef _LCD_I2C_ -#include <LiquidCrystal_I2C.h> -#endif - -#ifdef _LCD_4BIT_ -#include <LiquidCrystal.h> -#endif - - -/*! - @defined CHAR_WIDTH - @abstract Character witdth of the display, expressed in pixeles per character. -*/ -#define CHAR_WIDTH 5 - -/*! - @defined BACKLIGHT_PIN - @abstract LCD backlight pin definition. - @discussion AVR pin used for the backlight illumintation of the LCD. -*/ -#define BACKLIGHT_PIN 7 - -/*! - @defined TEMP_CAL_OFFSET - @abstract Temperature calibration offset. - @discussion This is the offset value that has to be modified to get a - correct temperature reading from the internal temperature sensor - of your AVR. -*/ -#define TEMP_CAL_OFFSET 334 - -/*! - @defined FILTER_ALP - @abstract Low pass filter alpha value - @discussion This value defines how much does the current reading, influences - the over all value. The smaller, the less influence the current - reading has over the overall result. -*/ -#define FILTER_ALP 0.1 - -extern unsigned int __bss_end; -extern unsigned int __heap_start; -extern void *__brkval; - -#ifdef _LCD_I2C_ -LiquidCrystal_I2C lcd(0x38); // set the LCD address to 0x20 for a 16 chars and 2 line display -#endif - -#ifdef _LCD_4BIT_ -LiquidCrystal lcd(12, 11, 5, 4, 3, 2, BACKLIGHT_PIN, POSITIVE); -#endif -const int CONTRAST_PIN = 9; -const int CONTRAST = 65; - - - -LCD *myLCD = &lcd; - -static double tempFilter; - - -/*! - @const charBitmap - @abstract Define Character bitmap for the bargraph. - @discussion Defines a character bitmap to represent a bargraph on a text - display. The bitmap goes from a blank character to full black. -*/ -const uint8_t charBitmap[][8] = { - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, - { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0 }, - { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 }, - { 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0 }, - { 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0 }, - { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 }, - { 0xe, 0x11, 0x11, 0x11, 0xe, 0, 0, 0 }, - { 0x6, 0x9, 0x9, 0x6, 0x0, 0, 0, 0} -}; - -/*! - @function - @abstract Return available RAM memory - @discussion This routine returns the ammount of RAM memory available after - initialising the C runtime. - @param - @result Free RAM available. -*/ - -static int freeMemory() -{ - int free_memory; - - if((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - - return free_memory; -} - -/*! - @function - @abstract Returns AVR328p internal temperature - @discussion Configures the ADC MUX for the temperature ADC channel and - waits for conversion and returns the value of the ADC module - @result The internal temperature reading - in degrees C -*/ - -static int readTemperature() -{ - ADMUX = 0xC8; // activate interal temperature sensor, - // using 1.1V ref. voltage - ADCSRA |= _BV(ADSC); // start the conversion - while (bit_is_set(ADCSRA, ADSC)); // ADSC is cleared when the conversion - // finishes - - // combine bytes & correct for temperature offset (approximate) - return ( (ADCL | (ADCH << 8)) - TEMP_CAL_OFFSET); -} - -/*! - @function - @abstract Braws a bargraph onto the display representing the value passed. - @discussion Draws a bargraph on the specified row using barLength characters. - @param value[in] Value to represent in the bargraph - @param row[in] Row of the LCD where to display the bargraph. Range (0, 1) - for this display. - @param barlength[in] Length of the bar, expressed in display characters. - @param start[in] Start bar character - @param end [in] End bar character - - @result None -*/ -static void drawBars ( int value, uint8_t row, uint8_t barLength, char start, - char end ) -{ - int numBars; - - // Set initial titles on the display - myLCD->setCursor (0, row); - myLCD->print (start); - - // Calculate the size of the bar - value = map ( value, -30, 50, 0, ( barLength ) * CHAR_WIDTH ); - numBars = value / CHAR_WIDTH; - - // Limit the size of the bargraph to barLength - if ( numBars > barLength ) - { - numBars = barLength; - } - myLCD->setCursor ( 1, row ); - - // Draw the bars - while ( numBars-- ) - { - myLCD->print ( char( 5 ) ); - } - - // Draw the fractions - numBars = value % CHAR_WIDTH; - myLCD->print ( char(numBars) ); - myLCD->setCursor (barLength + 1, row); - myLCD->print (end); - -} - -void setup () -{ - int i; - int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0])); - - Serial.begin ( 57600 ); - analogReference ( INTERNAL ); - -#ifdef _LCD_4BIT_ - pinMode(CONTRAST_PIN, OUTPUT); - lcd.backlight(); - digitalWrite(BACKLIGHT_PIN, HIGH); - analogWrite (CONTRAST_PIN, CONTRAST); -#else - pinMode ( BACKLIGHT_PIN, OUTPUT ); - digitalWrite(BACKLIGHT_PIN, HIGH); -#endif - - myLCD->begin ( 16, 2 ); - - // Load custom character set into CGRAM - for ( i = 0; i < charBitmapSize; i++ ) - { - myLCD->createChar ( i, (uint8_t *)charBitmap[i] ); - } - Serial.println ( freeMemory () ); - - myLCD->clear (); - myLCD->print ("Temp:"); - - tempFilter = readTemperature (); // Initialise the temperature Filter - -} - - -void loop () -{ - int temp; - - temp = readTemperature(); - tempFilter = ( FILTER_ALP * temp) + (( 1.0 - FILTER_ALP ) * tempFilter); - - myLCD->setCursor ( 8, 0 ); - myLCD->print (" "); - myLCD->setCursor ( 8, 0 ); - myLCD->print ( tempFilter, 1 ); - myLCD->setCursor ( 12, 0 ); - myLCD->print ( "\x07" ); - myLCD->print ("C"); - drawBars ( tempFilter, 1, 14, '-', '+' ); - - delay (200); -}
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/i2cLCDextraIO_tempLeonardo/i2cLCDextraIO_tempLeonardo.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,332 +0,0 @@ -// --------------------------------------------------------------------------- -// Created by Francisco Malpartida on 1/1/12. -// Copyright 2011 - Under creative commons license: -// Attribution-NonCommercial-ShareAlike CC BY-NC-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file i2CLCDextraIO_tempLeonardo.ino -// Temperature logging to demonstrate the I2CLCDextraIO library. -// -// @brief This application is a demostration file for the I2CLCDextraIO library -// that reads a temperature from the internal ATMEGA32U4 temperature sensor -// and displays it on the LCD. The application also demonstrates some of the -// methods of the library, such as loading custom characters to the LCD, -// moving around the LCD, and writing to it. -// -// @author F. Malpartida -// --------------------------------------------------------------------------- -#include <Arduino.h> -#include <Wire.h> -#include <LCD.h> - -#define _LCD_SR3W_ - -#ifdef _LCD_I2C_ -#include <LiquidCrystal_I2C.h> -#endif - -#ifdef _LCD_4BIT_ -#include <LiquidCrystal.h> -#endif - - -#ifdef _LCD_SR_ -#include <LiquidCrystal_SR.h> -#endif - -#ifdef _LCD_SR3W_ -#include <LiquidCrystal_SR3W.h> -#endif - - -/*! - @defined CHAR_WIDTH - @abstract Character witdth of the display, expressed in pixeles per character. -*/ -#define CHAR_WIDTH 5 - -/*! - @defined BACKLIGHT_PIN - @abstract LCD backlight pin definition. - @discussion AVR pin used for the backlight illumintation of the LCD. -*/ -#define BACKLIGHT_PIN 12 - -/*! - @defined STATUS_PIN - @abstract Status LED indicator. - @discussion Activity LED blinking indicating that the system is up. -*/ -#define STATUS_PIN 13 - -/*! - @defined LOOP_DELAY - @abstract Main loop delay. - @discussion Main loop delay executing temperature readings and LCD updates. -*/ -#define LOOP_DELAY 300 - -/*! - @defined TEMP_CAL_OFFSET - @abstract Temperature calibration offset. - @discussion This is the offset value that has to be modified to get a - correct temperature reading from the internal temperature sensor - of your AVR. -*/ -#define TEMP_CAL_OFFSET 282 - -/*! - @defined FILTER_ALP - @abstract Low pass filter alpha value - @discussion This value defines how much does the current reading, influences - the over all value. The smaller, the less influence the current - reading has over the overall result. -*/ -#define FILTER_ALP 0.1 - -/*! - @defined MIN_TEMP - @abstract Minimum temperature range for bargraph - -*/ -#define MIN_TEMP -10 - -/*! - @defined MAX_TEMP - @abstract Maximum temperature range for bargraph - -*/ -#define MAX_TEMP 50 - -extern unsigned int __bss_end; -extern unsigned int __heap_start; -extern void *__brkval; - - -// Initialise LCD module -// ----------------------------------------------------------------------------- -#ifdef _LCD_I2C_ -LiquidCrystal_I2C lcd(0x38); -#endif - -#ifdef _LCD_4BIT_ -LiquidCrystal lcd(12, 11, 5, 4, 3, 2, BACKLIGHT_PIN, POSITIVE); -const int CONTRAST_PIN = 9; -const int CONTRAST = 65; -#endif - -#ifdef _LCD_SR_ -LiquidCrystal_SR lcd(3,2,TWO_WIRE); -// | | -// | \-- Clock Pin -// \---- Data/Enable Pin -#endif - -#ifdef _LCD_SR3W_ -LiquidCrystal_SR3W lcd(3, 2, 4); -// | | -// | \-- Clock Pin -// \---- Data/Enable Pin -#endif - - -// LCD reference variable -LCD *myLCD = &lcd; - -// Temperature filter variable -static double tempFilter; - -/*! - @const charBitmap - @abstract Define Character bitmap for the bargraph. - @discussion Defines a character bitmap to represent a bargraph on a text - display. The bitmap goes from a blank character to full black. -*/ -const uint8_t charBitmap[][8] = { - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, - { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0 }, - { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 }, - { 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0 }, - { 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0 }, - { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 }, - { 0xe, 0x11, 0x11, 0x11, 0xe, 0, 0, 0 }, - { 0x6, 0x9, 0x9, 0x6, 0x0, 0, 0, 0} -}; - -/*! - @function - @abstract Return available RAM memory - @discussion This routine returns the ammount of RAM memory available after - initialising the C runtime. - @param - @result Free RAM available. -*/ -static int freeMemory() -{ - int free_memory; - - if((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - - return free_memory; -} - -/*! - @function - @abstract Returns AVR328p internal temperature - @discussion Configures the ADC MUX for the temperature ADC channel and - waits for conversion and returns the value of the ADC module - @result The internal temperature reading - in degrees C -*/ - -static int readTemperature() -{ - ADMUX = 0xC7; // activate interal temperature sensor, - // using 2.56V ref. voltage - ADCSRB |= _BV(MUX5); - - ADCSRA |= _BV(ADSC); // start the conversion - while (bit_is_set(ADCSRA, ADSC)); // ADSC is cleared when the conversion - // finishes - - // combine bytes & correct for temperature offset (approximate) - return ( (ADCL | (ADCH << 8)) - TEMP_CAL_OFFSET); -} - -/*! - @function - @abstract Braws a bargraph onto the display representing the value passed. - @discussion Draws a bargraph on the specified row using barLength characters. - @param value[in] Value to represent in the bargraph - @param row[in] Row of the LCD where to display the bargraph. Range (0, 1) - for this display. - @param barlength[in] Length of the bar, expressed in display characters. - @param start[in] Start bar character - @param end [in] End bar character - - @result None -*/ -static void drawBars ( int value, uint8_t row, uint8_t barLength, char start, - char end ) -{ - int numBars; - - // Set initial titles on the display - myLCD->setCursor (0, row); - myLCD->print (start); - - // Calculate the size of the bar - value = map ( value, MIN_TEMP, MAX_TEMP, 0, ( barLength ) * CHAR_WIDTH ); - numBars = value / CHAR_WIDTH; - - // Limit the size of the bargraph to barLength - if ( numBars > barLength ) - { - numBars = barLength; - } - myLCD->setCursor ( 1, row ); - - // Draw the bars - while ( numBars-- ) - { - myLCD->print ( char( 5 ) ); - } - - // Draw the fractions - numBars = value % CHAR_WIDTH; - myLCD->print ( char(numBars) ); - myLCD->setCursor (barLength + 1, row); - myLCD->print (end); - -} - -/*! - @function - @abstract Initialise the HW - @discussion Initialise the HW used within this application: UART, LCD & IOs - @param - @result -*/ - -static void initHW ( void ) -{ - int i; - int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0])); - - Serial.begin ( 57600 ); - - // Hardware initialise - // ------------------------------------ - - //ADCSRA |= (1 << ADEN); // Initialise ADC block (no need done by env) - - // Initialise LCD HW: backlight and LCD - // ------------------------------------- -#ifdef _LCD_4BIT_ - pinMode(CONTRAST_PIN, OUTPUT); - analogWrite (CONTRAST_PIN, CONTRAST); -#endif - -#ifdef _LCD_I2C_ - pinMode ( BACKLIGHT_PIN, OUTPUT ); - digitalWrite (BACKLIGHT_PIN, HIGH); -#endif - pinMode ( STATUS_PIN, OUTPUT ); - - myLCD->begin ( 20, 2 ); - // Load custom character set into CGRAM - // -------------------------------------------------------------------- - for ( i = 0; i < charBitmapSize; i++ ) - { - myLCD->createChar ( i, (uint8_t *)charBitmap[i] ); - } -} - -void setup () -{ - initHW(); - - Serial.println ( freeMemory () ); - myLCD->clear (); - myLCD->print ( F("Free Mem: ")); - myLCD->print ( freeMemory () ); - delay ( 2000 ); - myLCD->clear (); - myLCD->print (F("Temp:")); - myLCD->setCursor ( 8, 0 ); - - tempFilter = 0; - myLCD->print ( readTemperature() ); -} - - -void loop () -{ - int temp; - static byte status = 1; - - status ^= 1; - digitalWrite ( STATUS_PIN, status); - - temp = readTemperature(); - tempFilter = ( FILTER_ALP * temp) + (( 1.0 - FILTER_ALP ) * tempFilter); - - // Display the information to the LCD - myLCD->setCursor ( 8, 0 ); - myLCD->print (" "); - myLCD->setCursor ( 8, 0 ); - myLCD->print ( tempFilter, 1 ); - myLCD->setCursor ( 12, 0 ); - myLCD->print ( "\x07" ); - myLCD->print ("C"); - drawBars ( tempFilter, 1, 14, '-', '+' ); - - delay (LOOP_DELAY); -} \ No newline at end of file
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/examples/performanceLCD/performanceLCD.pde Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,480 +0,0 @@ -// Created by Francisco Malpartida on 20/08/11. -// Copyright 2011 - Under creative commons license 3.0: -// Attribution-ShareAlike CC BY-SA -// -// This software is furnished "as is", without technical support, and with no -// warranty, express or implied, as to its usefulness for any purpose. -// -// Thread Safe: No -// Extendable: Yes -// -// @file performanceLCD.h -// This sketch implements a simple benchmark for the New LiquidCrystal library. -// -// @brief -// This sketch provides a simple benchmark for the New LiquidCrystal library. It -// enables to test the varios classes provided by the library giving a performance -// reference. -// -// This library is only compatible with Arduino's SDK version 1.0 -// -// @version API 1.0.0 -// -// @author F. Malpartida - fmalpartida@gmail.com -// Contribution by flo - Florian@Fida.biz - for benchmarking SR -// --------------------------------------------------------------------------- -#include <Wire.h> - -#define _LCD_I2C_ - -#ifdef _LCD_I2C_ -#include <LiquidCrystal_I2C.h> -#endif - -#ifdef _LCD_4BIT_ -#include <LiquidCrystal.h> -#endif - -#ifdef _LCD_SR_ -#include <LiquidCrystal_SR.h> -#endif - -#ifdef _LCD_SR3W_ -#include <LiquidCrystal_SR3W.h> -#endif - -#ifdef _LCD_SR1_ -#include <LiquidCrystal_SR1.h> -#endif - -// C runtime variables -// ------------------- -#ifdef __AVR__ -extern unsigned int __bss_end; -extern unsigned int __heap_start; -extern void *__brkval; -#endif - -// Constants and definitions -// ------------------------- -// Definitions for compatibility with Arduino SDK prior to version 1.0 -#ifndef F -#define F(str) str -#endif - -/*! - @defined NUM_BENCHMARKS - @abstract Number of benchmarks in the project. - */ -#define NUM_BENCHMARKS 4 - -/*! - @defined ITERATIONS - @abstract Number of benchmarks iterations to perform. - */ -#define ITERATIONS 10 - -/*! - @defined LCD_ROWS - @abstract LCD rows - @discussion Defines the number of rows that the LCD has, normal LCD ranges are (1, 2, 4). - */ -#define LCD_ROWS 2 - -/*! - @defined LCD_COLUMNS - @abstract LCD available columns - @discussion Defines the number of colums that the LCD has, normal LCD ranges are (8, 16, 20). - */ -#define LCD_COLUMNS 16 - -/*! - @const Pin constant definitions - @abstract Define several constants required to manage the LCD backlight and contrast - */ -#ifdef _LCD_I2C_ -const int BACKLIGHT_PIN = 12; -const int CONTRAST_PIN = 0; // none -const int CONTRAST = 0; // none -#endif - -#ifdef _LCD_4BIT_ -const int CONTRAST_PIN = 9; -const int BACKLIGHT_PIN = 7; -const int CONTRAST = 120; -#endif - -#ifdef _LCD_SR_ -const int CONTRAST_PIN = 0; // not connected -const int BACKLIGHT_PIN = 0; // none -const int CONTRAST = 0; -#endif - -#ifdef _LCD_SR1_ -const int CONTRAST_PIN = 0; // not connected -const int BACKLIGHT_PIN = 0; // none -const int CONTRAST = 0; -#endif - -#ifdef _LCD_SR3W_ -const int CONTRAST_PIN = 0; // none -const int BACKLIGHT_PIN = 5; -const int CONTRAST = 0; -#endif - -/*! - @const charBitmap - @abstract Define Character bitmap for the bargraph. - @discussion Defines a character bitmap to represent a bargraph on a text - display. The bitmap goes from a blank character to full black. - */ -const uint8_t charBitmap[][8] = { - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, - { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0 }, - { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 }, - { 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0 }, - { 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0 }, - { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 } -}; - -/*! - @typedef t_benchmarkOp - @abstract Function pointer associated to each benchmark. - */ -typedef long (*t_benchmarkOp)( uint8_t ); - -/*! - @typedef t_timeBenchMarks - @abstract Structure to store results of the execution time of the benchmark. - @field benchmark: function pointer of the benchmark to be executed. - */ -typedef struct -{ - t_benchmarkOp benchmark; /**< Function pointer associated to the benchmark */ - long benchTime; /**< execution time for benchmark 1 in useconds */ - uint16_t numWrites; /**< Number of write cycles of the benchmark */ -} t_benchMarks; - - -// Main LCD objects -// ---------------- -#ifdef _LCD_I2C_ -LiquidCrystal_I2C lcd(0x38); // set the LCD address to 0x20 for a 16 chars and 2 line display -#endif - -#ifdef _LCD_4BIT_ -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); -#endif - -#ifdef _LCD_SR_ -LiquidCrystal_SR lcd(8,7,TWO_WIRE); -#endif - -#ifdef _LCD_SR1_ -LiquidCrystal_SR1 lcd(2); -#endif - -#ifdef _LCD_SR3W_ -LiquidCrystal_SR3W lcd(3, 2, 4); -#endif - -// benchMarks definitions -// ---------------------- -extern long benchmark1 ( uint8_t ); -extern long benchmark2 ( uint8_t ); -extern long benchmark3 ( uint8_t ); -extern long benchmark4 ( uint8_t ); - -//! @brief benchmark structure that will be initialised and -static t_benchMarks myBenchMarks[NUM_BENCHMARKS] = -{ - { benchmark1, 0, (LCD_ROWS * LCD_COLUMNS) + 2 }, - { benchmark2, 0, LCD_ROWS * LCD_COLUMNS * 6 * 2 }, - { benchmark3, 0, 40 + 2 }, - { benchmark4, 0, 40 + 2 } -}; - -// Static methods -// -------------- -/*! - @function freeMemory - @abstract Return available RAM memory - @discussion This routine returns the ammount of RAM memory available after - initialising the C runtime. - @param - @return Free RAM available, -1 for non AVR microcontrollers - */ -static int freeMemory ( void ) -{ -#ifdef __AVR__ - int free_memory; - - if((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - - return free_memory; -#else - return -1; -#endif - -} - -/*! - @function LCDSetup - @abstract Initialise LCD associated pins and initialise the LCD object - with its geometry. - @discussion Initialise the LCD object and make it ready for operation by - setting up the LCD geometry, i.e. LCD character size. Initialise - and configure all associated control pins such as backlight and - contras pin if necessary. - - @param[in] charBitmapSize: contrasts pin associated to the contrast (should be an - analog pin). 0 if contrast pin is not required. - @param[in] backlight: backlight pin associated to the LCD backlight. - @param[in] cols: number of LCD columns normal values (1, 2, 4) - @param[in] rows: number of LCD rows normal values (8, 16, 20) - */ -static void LCDSetup ( uint8_t contrasPin, uint8_t backlight, uint8_t cols, uint8_t rows ) -{ - // If our setup uses a PWM to control the backlight, configure it - // -------------------------------------------------------------- - if ( contrasPin != 0 ) - { - pinMode ( contrasPin, OUTPUT ); - analogWrite ( contrasPin, CONTRAST ); - } - // Setup backlight pin - if ( backlight != 0 ){ - pinMode(backlight, OUTPUT); - digitalWrite(backlight, HIGH); - } - - lcd.begin ( cols, rows ); - lcd.clear ( ); -} - - -/*! - @function LCDLoadCharacters - @abstract Loads onto the LCD the character set for the benchmark. - @discussion Loads onto the LCD the character set that will be used throughout - the benchmark. - - @param[in] charBitmapSize: number of characters to load to the LCD. - */ -static void LCDLoadCharacters ( int numChars ) -{ - // Load custom character set into CGRAM - for ( int i = 0; i < numChars; i++ ) - { - lcd.createChar ( i, (uint8_t *)charBitmap[i] ); - } -} - - -// Benchmarks -// ---------- -/*! - @function benchmark1 - @abstract writes to the LCD a full set of characters loaded on the LCD - memory. - @discussion Writes to all the positions of the LCD a fixed pattern from - memory. For every line it writes, it positions the cursor. - The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2. - It returns the cumulative time used by all the iterations. - - @param[in] iterations: number of iterations the benchmark is executed before - returning the time taken by all iterations. - @return The time take to execute iterations number of benchmarks. - */ -long benchmark1 ( uint8_t iterations ) -{ - unsigned long time, totalTime = 0; - int i, j; - - while ( iterations > 0 ) - { - // Clear the LCD - lcd.clear ( ); - - time = micros (); - for ( i = 0; i < LCD_ROWS; i++ ) - { - lcd.setCursor ( 0, i ); - for ( j = 0; j < LCD_COLUMNS; j++ ) - { - lcd.print (char(5)); - } - } - totalTime += ( micros() - time ); - delay ( 200 ); // it doesn't keep up with the LCD refresh rate. - iterations--; - } - return ( totalTime ); -} - -/*! - @function benchmark2 - @abstract writes to the LCD a full set of characters loaded on the LCD - memory one line pixel at the time - @discussion Writes to all the positions of the LCD a fixed pattern from - memory each patern take 6 write operations to the LCD. For every - character it writes it sets the cursor possition. - The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS * 6. - It returns the cumulative time used by all the iterations. - - @param[in] iterations: number of iterations the benchmark is executed before - returning the time taken by all iterations. - @return The time take to execute iterations number of benchmarks. - */ -long benchmark2 ( uint8_t iterations ) -{ - unsigned long time, totalTime = 0; - int i, j, k; - - while ( iterations > 0 ) - { - // Clear the LCD - lcd.clear ( ); - - time = micros (); - - for ( i = 0; i < LCD_ROWS; i++ ) - { - for ( j = 0; j < LCD_COLUMNS; j++ ) - { - for ( k = 0; k <= 5; k++ ) - { - lcd.setCursor ( j, i ); - lcd.print (char(k)); - } - } - } - totalTime += ( micros() - time ); - iterations--; - } - return ( totalTime ); -} - -/*! - @function benchmark3 - @abstract writes to the LCD a full set of characters from memory. - @discussion Writes to all the positions of the LCD a fixed pattern from - RAM. For every line it writes, it positions the cursor. - The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2. - It returns the cumulative time used by all the iterations. - - @param[in] iterations: number of iterations the benchmark is executed before - returning the time taken by all iterations. - @return The time take to execute iterations number of benchmarks. - */ -long benchmark3 ( uint8_t iterations ) -{ - unsigned long time, totalTime = 0; - int i; - - while ( iterations > 0 ) - { - // Clear the LCD - lcd.clear ( ); - - time = micros (); - for ( i = 0; i < LCD_ROWS; i++ ) - { - lcd.setCursor ( 0, i ); - lcd.print ( "####################" ); - } - totalTime += ( micros() - time ); - delay ( 200 ); // it doesn't keep up with the LCD refresh rate. - iterations--; - } - return ( totalTime ); -} - -/*! - @function benchmark4 - @abstract writes to the LCD a full set of characters from memory. - @discussion Writes to all the positions of the LCD a fixed pattern from - flash. For every line it writes, it positions the cursor. - The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2. - It returns the cumulative time used by all the iterations. - - @param[in] iterations: number of iterations the benchmark is executed before - returning the time taken by all iterations. - @return The time take to execute iterations number of benchmarks. - */ -long benchmark4 ( uint8_t iterations ) -{ - unsigned long time, totalTime = 0; - int i; - - while ( iterations > 0 ) - { - // Clear the LCD - lcd.clear ( ); - - time = micros (); - for ( i = 0; i < LCD_ROWS; i++ ) - { - lcd.setCursor ( 0, i ); - lcd.print ( F("####################") ); - } - totalTime += ( micros() - time ); - delay ( 200 ); // it doesn't keep up with the LCD refresh rate. - iterations--; - } - return ( totalTime ); -} - -// Main system setup -// ----------------- -void setup () -{ - Serial.begin ( 57600 ); -#ifdef __AVR__ - Serial.print ( F("Free mem: ") ); - Serial.println ( freeMemory () ); -#endif - - // Initialise the LCD - LCDSetup ( CONTRAST_PIN, BACKLIGHT_PIN, LCD_COLUMNS, LCD_ROWS ); - LCDLoadCharacters ( (sizeof(charBitmap ) / sizeof (charBitmap[0])) ); -} - - -// Main system loop -// ---------------- -void loop () -{ - int i; - - lcd.setCursor ( 0, 0 ); - lcd.clear ( ); - - // Run benchmark - for ( i = 0; i < NUM_BENCHMARKS; i++ ) - { - myBenchMarks[i].benchTime = - (myBenchMarks[i].benchmark (ITERATIONS))/ITERATIONS; - Serial.println (i); - } - - float fAllWrites=0.0; - - for ( i = 0; i < NUM_BENCHMARKS; i++ ) - { - Serial.print ( F("benchmark") ); - Serial.print ( i ); - Serial.print ( F(": ") ); - Serial.print ( myBenchMarks[i].benchTime ); - Serial.print ( F(" us - ") ); - Serial.print ( F(" write: ") ); - Serial.print ( myBenchMarks[i].benchTime / (float)myBenchMarks[i].numWrites ); - Serial.println ( F(" us") ); - fAllWrites += myBenchMarks[i].benchTime / (float)myBenchMarks[i].numWrites; - } - Serial.print( F("avg. write: ") ); - Serial.println( fAllWrites / (float)NUM_BENCHMARKS ); - } \ No newline at end of file
--- a/service/busyboxArduino/LiquidCrystal_V1.2.1/LiquidCrystal/keywords.txt Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -########################################### -# Syntax Coloring Map For LiquidCrystal_I2C -########################################### - -########################################### -# Datatypes (KEYWORD1) -########################################### - -LiquidCrystal_SR KEYWORD1 -LiquidCrystal_I2C KEYWORD1 -LiquidCrystal_SR3W KEYWORD1 -LiquidCrystal KEYWORD1 -LCD KEYWORD1 - -########################################### -# Methods and Functions (KEYWORD2) -########################################### -begin KEYWORD2 -clear KEYWORD2 -home KEYWORD2 -noDisplay KEYWORD2 -display KEYWORD2 -noBlink KEYWORD2 -blink KEYWORD2 -noCursor KEYWORD2 -cursor KEYWORD2 -scrollDisplayLeft KEYWORD2 -scrollDisplayRight KEYWORD2 -leftToRight KEYWORD2 -rightToLeft KEYWORD2 -moveCursorLeft KEYWORD2 -moveCursorRight KEYWORD2 -autoscroll KEYWORD2 -noAutoscroll KEYWORD2 -createChar KEYWORD2 -setCursor KEYWORD2 -print KEYWORD2 -write KEYWORD2 -println KEYWORD2 -backlight KEYWORD2 -noBacklight KEYWORD2 -on KEYWORD2 -off KEYWORD2 -setBacklightPin KEYWORD2 -setBacklight KEYWORD2 -########################################### -# Constants (LITERAL1) -########################################### -POSITIVE LITERAL1 -NEGATIVE LITERAL1 -BACKLIGHT_ON LITERAL1 -BACKLIGHT_OFF LITERAL1 \ No newline at end of file
--- a/service/busyboxArduino/busybox.py Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -from __future__ import division -import serial, struct, json, sys - -from rdflib import Namespace, Literal -sys.path.append("/my/site/magma") -from stategraph import StateGraph -import klein -from twisted.internet import task -import random, time - -import restkit -reasoning = restkit.Resource("http://bang:9071/", timeout=1) -ROOM = Namespace("http://projects.bigasterisk.com/room/") - -def sendOneShot(stmt): - try: - t1 = time.time() - print "post to reasoning", stmt - p = reasoning.post("oneShot", - headers={"content-type": "text/n3"}, - payload=("%s %s %s ." % - tuple(n.n3() for n in stmt))) - except restkit.errors.RequestFailed: - print "oneShot failed" - return - print "posted in %.04f sec. %r" % (time.time() - t1, - p.body_string()) - - -class Busybox(object): - def __init__(self, port='/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A4001lVK-if00-port0'): - self.serial = serial.Serial(port, baudrate=115200, timeout=.2) - - def poll(self): - for tries in range(5): - self.serial.write('\x60\x00') - line = self.serial.readline() - if not line.startswith('{'): - continue - if tries > 0: - print "after %s tries" % tries - return json.loads(line) - return {'error': 'invalid response'} - - def writeMessage(self, row, col, text): - msg = struct.pack('BBBBB', 0x60, 0x01, row, col, len(text)) + text - self.serial.write(msg) - - def setBacklight(self, level): - self.serial.write(struct.pack('BBB', 0x60, 0x02, level)) - - def sendIr(self, remote, command): - code = { - 'led_22_key': { - # LED618 remote command byte (addr is ff) - # see https://github.com/alistairallan/RgbIrLed/blob/master/RgbIrLed.cpp#L44 - 'ON': 0xE0, - 'OFF': 0x60, - 'BRIGHTNESS_UP': 0xA0, - 'BRIGHTNESS_DOWN': 0x20, - 'FLASH': 0xF0, - 'STROBE': 0xE8, - 'FADE': 0xD8, - 'SMOOTH': 0xC8, - 'RED': 0x90, 'GREEN': 0x10, 'BLUE': 0x50, 'WHITE': 0xD0, - 'ORANGE': 0xB0, 'YELLOW_DARK': 0xA8, 'YELLOW_MEDIUM': 0x98, 'YELLOW_LIGHT': 0x88, - 'GREEN_LIGHT': 0x30, 'GREEN_BLUE1': 0x28, 'GREEN_BLUE2': 0x18, 'GREEN_BLUE3': 0x08, - 'BLUE_RED': 0x70, 'PURPLE_DARK': 0x68, 'PURPLE_LIGHT': 0x58, 'PINK': 0x48, - }, - 'led_44_key': { - # 44 key remote. command chart: http://blog.allgaiershops.com/2012/05/ - 'up': 0x3A, 'down': 0xBA, 'play': 0x82, 'power': 0x02, - 'red0': 0x1A, 'grn0': 0x9A, 'blu0': 0xA2, 'wht0': 0x22, - 'red1': 0x2A, 'grn1': 0xAA, 'blu1': 0x92, 'wht1': 0x12, - 'red2': 0x0A, 'grn2': 0x8A, 'blu2': 0xB2, 'wht2': 0x32, - 'red3': 0x38, 'grn3': 0xB8, 'blu3': 0x78, 'wht3': 0xF8, - 'red4': 0x18, 'grn4': 0x98, 'blu4': 0x58, 'wht4': 0xD8, - 'RUp': 0x28, 'GUp': 0xA8, 'BUp': 0x68, - 'RDn': 0x08, 'GDn': 0x88, 'BDn': 0x48, - 'Quick': 0xE8, 'Slow': 0xC8, - 'DIY1': 0x30, 'DIY2': 0xB0, 'DIY3': 0x70, 'DIY4': 0x10, 'DIY5': 0x90, 'DIY6': 0x50, - 'AUTO': 0xF0, - 'Flash': 0xD0, - 'JMP3': 0x20, 'JMP7': 0xA0, - 'Fade': 0x60, 'Fade7': 0xE0, - } - } - - address = { - 'led_22_key': 0x00, - 'led_44_key': 0x00, - }[remote] - self.serial.write(struct.pack('BBBB', 0x60, 0x03, address, code[remote][command])) - time.sleep(.2) - - -bb = Busybox() -words = open('/usr/share/dict/words').readlines() - -while 1: - bb.sendIr('led_22_key', 'RED') - bb.sendIr('led_22_key', 'BRIGHTNESS_DOWN') - bb.sendIr('led_22_key', 'BRIGHTNESS_DOWN') - bb.sendIr('led_22_key', 'BRIGHTNESS_DOWN') - bb.sendIr('led_22_key', 'BLUE') - bb.sendIr('led_22_key', 'BRIGHTNESS_DOWN') - bb.sendIr('led_22_key', 'BRIGHTNESS_DOWN') - bb.sendIr('led_22_key', 'BRIGHTNESS_DOWN') - - - -class Poller(object): - def __init__(self): - self.lastWordTime = 0 - self.last = None - self.s1 = [] - - def poll(self): - try: - self.tryPoll() - except Exception as e: - print "poll failed: %r" % e - - def tryPoll(self): - now = time.time() - if now - self.lastWordTime > 1: - msg = '%15s' % random.choice(words).strip()[:15] - bb.writeMessage(1, 1, msg) - self.lastWordTime = now - self.last = bb.poll() - print self.last - if 'slider1' in self.last: - self.s1 = self.s1[-5:] + [self.last['slider1']] - if len(self.s1) > 4: - median = sorted(self.s1)[2] - bb.setBacklight(min(255, median // 4)) - if 'keyDown' in self.last: - keyNum = self.last['keyDown'] - sendOneShot((ROOM['ariBed/button%s' % keyNum], - ROOM['change'], - ROOM['down'])) - if self.last['motion']: - bb.sendIr('led_22_key', 'ON') - else: - bb.sendIr('led_22_key', 'OFF') - - -@klein.route('/graph', methods=['GET']) -def getGraph(request): - g = StateGraph(ROOM.busybox) - g.add((ROOM.busybox, ROOM.localHour, Literal('x'))) - for attr in ['slider1', 'slider2', 'slider3', 'slider4']: - # needs: smoothing, exp curve correction - g.add((ROOM['busybox/%s' % attr], ROOM.value, Literal(round(poller.last[attr] / 1021, 3)))) - g.add((ROOM['busybox/motion'], ROOM.value, Literal(poller.last['motion']))) - request.setHeader('Content-type', 'application/x-trig') - return g.asTrig() - -poller = Poller() -task.LoopingCall(poller.poll).start(.05) - -# todo: watch reasoning graph. put lines on display. send updated ir codes. - -klein.run('0.0.0.0', port=9056) -
--- a/service/busyboxArduino/main.ino Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/* -D0 <--------- -D1 lcd rw -D2 <--------- -D3 ir out ----- -D4 lcd 4 -D5 lcd 5 -D6 lcd 6 -D7 lcd 7 -D8 lcd rs -D9 lcd en -D10 lcd backlight -D11 tbd <------------ -D12 motion in <-------- -D13 debug led <-------- - - */ -#include <Arduino.h> -#include <LiquidCrystal.h> -#include "DFR_Key.h" -#include "IRremote.h" - -#define motionIn 12 - - -// see http://www.dfrobot.com/image/data/DFR0009/LCDKeypad%20Shield%20V1.0%20SCH.pdf -#define I2C_ADDR 0x27 // I2C address of PCF8574A -#define BACKLIGHT_PIN 10 -#define En_pin 9 -#define Rw_pin 1 -#define Rs_pin 8 -#define D4_pin 4 -#define D5_pin 5 -#define D6_pin 6 -#define D7_pin 7 - -LiquidCrystal lcd(Rs_pin, Rw_pin, En_pin, D4_pin, D5_pin, D6_pin, D7_pin, BACKLIGHT_PIN, POSITIVE); -DFR_Key keypad; - -byte backlightStandard = 0; -byte backlightCurrent = 0; -byte backlightKeypressBoost = 30; - -int lastKey = -1; -int lastUnsentKeydown = -1; -uint16_t steps = 0; -uint16_t stepDelayPerBrightnessFade = 2048; - -// uses pin 3 -IRsend irsend; - -void sendnec(byte addr, byte cmd) { - uint32_t w = - ((uint32_t(addr) << 24) & 0xff000000) | - (((~uint32_t(addr)) << 16) & 0x00ff0000) | - ((uint32_t(cmd) << 8) & 0x0000ff00) | - ((~uint32_t(cmd)) & 0x000000ff); - irsend.sendNEC(w, 32); -} - -void setup(void) { - pinMode(motionIn, INPUT); - digitalWrite(motionIn, 1); - - Serial.begin(115200); - keypad.setRate(10); - lcd.begin(16,2); -} - - -void loop() { - while (Serial.available() <= 2) { - int localKey = keypad.getKey(); - if (localKey != SAMPLE_WAIT) { - if (localKey != lastKey) { - if (lastKey == 0) { - backlightCurrent = min(255, backlightStandard + - backlightKeypressBoost); - lastUnsentKeydown = localKey; - } - lastKey = localKey; - } - } - - if (backlightCurrent > backlightStandard) { - steps++; - if (steps % stepDelayPerBrightnessFade == 0) { - backlightCurrent--; - } - } else if (backlightCurrent < backlightStandard) { - backlightCurrent = backlightStandard; - } - lcd.setBacklight(backlightCurrent); - } - byte i = Serial.read(); - if (i != 0x60) { - return; - } - i = Serial.read(); // command - if (i == 0) { // get status - Serial.print('{'); - if (lastUnsentKeydown != -1) { - Serial.print("\"keyDown\":"); - Serial.print(lastUnsentKeydown); - Serial.print(","); - lastUnsentKeydown = -1; - } - Serial.print("\"slider1\":"); Serial.print(analogRead(1)); - Serial.print(",\"slider2\":"); Serial.print(analogRead(2)); - Serial.print(",\"slider3\":"); Serial.print(analogRead(3)); - Serial.print(",\"slider4\":"); Serial.print(analogRead(4)); - Serial.print(",\"motion\":"); Serial.print(digitalRead(motionIn)); - Serial.print("}\n"); - } else if (i == 1) { // write text - while (Serial.available() < 3) NULL; - byte row = Serial.read(); - byte col = Serial.read(); - byte nchars = Serial.read(); - char buf[32]; - char *p=buf; - while (nchars--) { - while (Serial.available() < 1) NULL; - *(p++) = Serial.read(); - } - *p = 0; - lcd.setCursor(row, col); - lcd.print(buf); - } else if (i == 2) { // set backlight - while (Serial.available() < 1) NULL; - backlightStandard = Serial.read(); - } else if (i == 3) { // IR NEC protocol - while (Serial.available() < 2) NULL; - byte addr = Serial.read(); - sendnec(addr, Serial.read()); - } else { - // unknown command - } -}
--- a/service/busyboxArduino/makefile Sun Apr 21 01:24:50 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -BOARD_TAG = diecimila -USER_LIB_PATH := $(realpath LiquidCrystal_V1.2.1/) -ARDUINO_LIBS = LiquidCrystal Wire -MONITOR_PORT = /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A4001lVK-if00-port0 - -include /usr/share/arduino/Arduino.mk - -setup: - ln -sf LiquidCrystal_V1.2.1/LiquidCrystal/LiquidCrystal.cpp LiquidCrystal.cpp - ln -sf IRremote/IRremote.cpp IRremote.cpp - ln -sf IRremote/IRremote.h IRremote.h - ln -sf IRremote/IRremoteInt.h IRremoteInt.h - -