Nathan Yonkee / Mbed OS Seeed_Grove_4_Digit_Display_Clock

Dependencies:   Data_Clock_Pair Seeed_Chainable_LED Seeed_Four_Digit_Disp Seeed_IR_Temp_Sensor Seeed_Led_Bar

Fork of Seeed_Grove_4_Digit_Display_Clock by Seeed

Files at this revision

API Documentation at this revision

Comitter:
tulanthoar
Date:
Sun May 21 19:46:36 2017 +0000
Parent:
17:71c14845db51
Child:
19:ad7bc3db9f1a
Commit message:
move Seeed classes to libraries for easy reuse

Changed in this revision

DataClockPair.h Show diff for this revision Revisions of this file
Data_Clock_Pair.lib Show annotated file Show diff for this revision Revisions of this file
SeeedChainableLED.h Show diff for this revision Revisions of this file
SeeedFourDigitDisp.h Show diff for this revision Revisions of this file
SeeedIRTempSensor.h Show diff for this revision Revisions of this file
SeeedLedBar.h Show diff for this revision Revisions of this file
Seeed_Chainable_LED.lib Show annotated file Show diff for this revision Revisions of this file
Seeed_Four_Digit_Disp.lib Show annotated file Show diff for this revision Revisions of this file
Seeed_IR_Temp_Sensor.lib Show annotated file Show diff for this revision Revisions of this file
Seeed_Led_Bar.lib Show annotated file Show diff for this revision Revisions of this file
--- a/DataClockPair.h	Sun May 21 13:33:34 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#ifndef DATA_CLOCK_PAIR_H
-#define DATA_CLOCK_PAIR_H
-#include "mbed.h"
-struct DataClockPair{
-    typedef PinName ClockPin;
-    typedef PinName DataPin;
-    ClockPin clockPin;
-    DataPin dataPin;
-};
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Data_Clock_Pair.lib	Sun May 21 19:46:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/tulanthoar/code/Data_Clock_Pair/#6d9fab76ca5b
--- a/SeeedChainableLED.h	Sun May 21 13:33:34 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/**
- * @file SeeedChainableLED.h
- * @brief control the chainable LED module from Seeed Studios
- * @author Nathan Yonkee
- * @version 1.0
- * @date 2017-04-20
- */
-#ifndef SEEED_CHAINABLE_LED_H
-#define SEEED_CHAINABLE_LED_H
-#include "mbed.h"
-#include "DataClockPair.h"
-
-class SeeedChainableLED {
-  private:
-    DigitalOut datPin_;
-    DigitalOut clkPin_;
-    void start_cmd();
-    void stop_cmd();
-    void pin_delay(int delay_us = 6);
-    void send_byte(int byte);
-    void send_color(int r, int g, int b);
-  public:
-    void set_color_rgb(int r, int g, int b, int led = 0);
-    void clear_led();
-    void turn_on();
-    SeeedChainableLED (DataClockPair pins);
-};
-
-SeeedChainableLED::SeeedChainableLED(DataClockPair pins) : datPin_(pins.dataPin), clkPin_(pins.clockPin) {
-    clear_led();
-}
-
-void SeeedChainableLED::start_cmd() {
-    send_byte(0x00);
-    send_byte(0x00);
-    send_byte(0x00);
-    send_byte(0x00);
-}
-
-void SeeedChainableLED::stop_cmd() {
-    start_cmd();
-}
-
-void SeeedChainableLED::clear_led() {
-    set_color_rgb(0,0,0);
-}
-
-void SeeedChainableLED::turn_on() {
-    set_color_rgb(255,255,255);
-}
-
-void SeeedChainableLED::pin_delay(int delay_us) {
-    wait_us(delay_us);
-}
-
-void SeeedChainableLED::set_color_rgb(int r, int g, int b, int led) {
-    start_cmd();
-    send_color(r, g, b);
-    stop_cmd();
-}
-
-void SeeedChainableLED::send_color(int red, int green, int blue) {
-    // Start by sending a byte with the format "1 1 /B7 /B6 /G7 /G6 /R7 /R6"
-    int prefix = 0b11000000;
-    if ((blue & 0x80) == 0)     prefix|= 0b00100000;
-    if ((blue & 0x40) == 0)     prefix|= 0b00010000;
-    if ((green & 0x80) == 0)    prefix|= 0b00001000;
-    if ((green & 0x40) == 0)    prefix|= 0b00000100;
-    if ((red & 0x80) == 0)      prefix|= 0b00000010;
-    if ((red & 0x40) == 0)      prefix|= 0b00000001;
-    send_byte(prefix);
-    // Now send the 3 colors
-    send_byte(blue);
-    send_byte(green);
-    send_byte(red);
-}
-
-void SeeedChainableLED::send_byte(int byte) {
-    for (int i = 0; i < 8; i++) {
-        pin_delay();
-        datPin_ = byte & 0x80;
-        byte <<= 1;
-        clkPin_ = 0;
-        pin_delay();
-        clkPin_ = 1;
-    }
-}
-
-#endif
--- a/SeeedFourDigitDisp.h	Sun May 21 13:33:34 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-#ifndef SEEED_FOUR_DIGIT_DISP_H
-#define SEEED_FOUR_DIGIT_DISP_H
-#include "mbed.h"
-#include "DataClockPair.h"
-
-class SeeedFourDigitDisp {
-  private:
-    int digitTable_[17] = {0x3f, 0x06, 0x5b, 0x4f,
-                          0x66, 0x6d, 0x7d, 0x07,
-                          0x7f, 0x6f, 0x77, 0x7c,
-                          0x39, 0x5e, 0x79, 0x71,
-                          0x00
-                         };
-    static const int onByte_ = 0x88;
-    static const int fixedAddrByte_ = 0x44;
-    static const int positionBit_ = 0xc0;
-    static const int nullDigit_ = 16;
-    static const int colonBit_ = 0x80;
-    void start_cmd();
-    void stop_cmd();
-    DigitalOut datPin_;
-    DigitalOut clkPin_;
-    void pin_delay(int delay_us = 1);
-    void send_byte(int byte);
-  public:
-    int brightness = 7;
-    bool colonFlag = false;
-    void set_digit(int pos, int digit);
-    void set_integer(int value);
-    void clear_display();
-    void turn_on();
-    SeeedFourDigitDisp (DataClockPair pins);
-};
-
-SeeedFourDigitDisp::SeeedFourDigitDisp(DataClockPair pins) : datPin_(pins.dataPin, 1), clkPin_(pins.clockPin, 1) {
-    clear_display();
-}
-
-void SeeedFourDigitDisp::pin_delay(int delay_us) {
-    wait_us(delay_us);
-}
-
-void SeeedFourDigitDisp::start_cmd() {
-    datPin_ = !datPin_;
-}
-
-void SeeedFourDigitDisp::stop_cmd() {
-    datPin_ = 0;
-    clkPin_ = !clkPin_;
-    pin_delay();
-    clkPin_ = !clkPin_;
-    datPin_ = !datPin_;
-}
-
-void SeeedFourDigitDisp::send_byte(int byte) {
-    byte |= 0x100; // bring data high for ack after 8 bits
-    for (int i = 0; i < 9; ++i) {
-        pin_delay();
-        clkPin_ = !clkPin_;
-        pin_delay();
-        datPin_ = byte & 1;
-        byte >>= 1;
-        pin_delay();
-        clkPin_ = !clkPin_;
-    }
-}
-
-void SeeedFourDigitDisp::set_digit(int pos, int digit) {
-    int flaggedDigit = digitTable_[digit] | (colonFlag ? colonBit_ : 0);
-    start_cmd();          //start signal sent to TM1637 from MCU
-    send_byte(fixedAddrByte_);
-    stop_cmd();
-    start_cmd();
-    send_byte(pos|positionBit_);
-    send_byte(flaggedDigit);
-    stop_cmd();
-    start_cmd();
-    send_byte(onByte_ + brightness);
-    stop_cmd();
-}
-
-void SeeedFourDigitDisp::turn_on() {
-    start_cmd();
-    send_byte(onByte_+brightness);
-    stop_cmd();
-}
-
-void SeeedFourDigitDisp::clear_display() {
-    set_digit(0,nullDigit_);
-    set_digit(1,nullDigit_);
-    set_digit(2,nullDigit_);
-    set_digit(3,nullDigit_);
-}
-
-
-void SeeedFourDigitDisp::set_integer(int value) {
-    clear_display();
-    if( value < 0 ) {
-        colonFlag = true;
-        set_digit(0, 0);
-        return;
-    }
-    if( value > 9999 ) {
-        colonFlag = true;
-        set_digit(0, 15);
-        return;
-    }
-    for (int i = 3; i >= 0; --i) {
-        int digit = value % 10;
-        set_digit(i, digit);
-        value -= digit;
-        if(value < 10) return;
-        value /= 10;
-    }
-}
-
-
-#endif
--- a/SeeedIRTempSensor.h	Sun May 21 13:33:34 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/* #include <cmath> */
-#include "mbed.h"
-namespace IRTempSensor{
-#define SUR_TEMP_PIN PA_3 // Analog input pin connect to temperature sensor SUR pin
-#define OBJ_TEMP_PIN PC_0 // Analog input pin connect to temperature sensor OBJ pin
-
-double measuresureTemp(PinName surPin) {
-    AnalogIn surTPin(surPin);
-    float volts, resistance, temperature;
-    volts = 0;
-    for (int i = 0; i < 100; i++) {
-        volts += surTPin.read();
-        wait_us(10);
-    }
-    volts *= 3.3/100;
-    resistance = 2000000*volts/(2.5-volts);
-    temperature = 1/(log(resistance/100000)/3964 +(1/298.15)) - 273.15;
-    return temperature;
-}
-
-float measureObjectTemp(PinName surPin, PinName objPin) {
-    AnalogIn objTPin(objPin);
-    float objV = 0;
-    for (int i = 0; i < 100; i++) {
-        objV += objTPin.read();
-        wait_us(10);
-    }
-    objV *= 3.3/100;
-    /* float pileSignal= objV - 2.5*17.4/(17.4+64); */
-    float pileSignal = objV - 0.52;
-    pileSignal *= 0.01;
-    float ts = measuresureTemp(surPin) + 273.15;
-    /* float calib = 1+(298.15 - ts)*0.0011; */
-    float calib = 1;
-    float k = 3.45*pow(10,-13)*calib;
-    float kRecip = 2976078405624.9985;
-    float kRecipAmp = kRecip * 0.01;
-    /* float objT = (pileSignal*kRecip + ts*ts*ts*ts); */
-    float objT = (objV*kRecipAmp -0.51*kRecipAmp + ts*ts*ts*ts);
-    return pow(objT,0.25) - 273.15;
-    /* return pileSignal*1000; */
-    /* return objV*100; */
-}};
--- a/SeeedLedBar.h	Sun May 21 13:33:34 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-#ifndef SEEED_LED_BAR_H
-#define SEEED_LED_BAR_H
-#include "mbed.h"
-#include "DataClockPair.h"
-
-class SeeedLedBar {
-  private:
-    DigitalOut datPin_;
-    DigitalOut clkPin_;
-    void pin_delay(int delay_us = 2);
-    static const int glbCmdMode_ = 0x00;
-    void send_sixtn_bits(int sixtnBits);
-    void set_leds(int (&ledPower )[10]);
-  public:
-    SeeedLedBar(DataClockPair pins);
-    void ten_on();
-    void ten_off();
-    void ten_set(int (&ledPower )[10]);
-};
-
-SeeedLedBar::SeeedLedBar(DataClockPair pins) : datPin_(pins.dataPin), clkPin_(pins.clockPin) { }
-
-void SeeedLedBar::pin_delay(int delay_us) {
-    wait_us(delay_us);
-}
-
-void SeeedLedBar::send_sixtn_bits(int sixtnBits) {
-    for (int i = 0; i < 16; i++) {
-        pin_delay();
-        datPin_ = sixtnBits & 0x8000;
-        sixtnBits <<= 1;
-        pin_delay();
-        clkPin_ = !clkPin_;
-    }
-}
-
-void SeeedLedBar::set_leds(int (&ledPower )[10]) {
-    send_sixtn_bits(glbCmdMode_);
-    for (auto& i : ledPower) send_sixtn_bits(i);
-    // Two extra empty bits for padding the command to the correct length
-    send_sixtn_bits(0x00);
-    send_sixtn_bits(0x00);
-    pin_delay();
-    datPin_ = 0;
-    pin_delay();
-    for (int i = 0; i < 4; i++) {
-        pin_delay();
-        datPin_ = 1;
-        pin_delay();
-        datPin_ = 0;
-    }
-}
-
-void SeeedLedBar::ten_on() {
-    int all_on[10] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-    set_leds(all_on);
-}
-
-void SeeedLedBar::ten_off() {
-    int all_off[10] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-    set_leds(all_off);
-}
-
-void SeeedLedBar::ten_set(int (&ledPower )[10]) {
-    set_leds(ledPower);
-}
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Seeed_Chainable_LED.lib	Sun May 21 19:46:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/tulanthoar/code/Seeed_Chainable_LED/#fab321797d4b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Seeed_Four_Digit_Disp.lib	Sun May 21 19:46:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/tulanthoar/code/Seeed_Four_Digit_Disp/#b6d9c94486d5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Seeed_IR_Temp_Sensor.lib	Sun May 21 19:46:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/tulanthoar/code/Seeed_IR_Temp_Sensor/#fa362542d13e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Seeed_Led_Bar.lib	Sun May 21 19:46:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/tulanthoar/code/Seeed_Led_Bar/#786a9861af5c