Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Adafruit_Trellis_Hello_World
Adafruit_Trellis.h
00001 #ifndef _BV 00002 #define _BV(bit) (1 << (bit)) 00003 #endif 00004 00005 #include "mbed.h" 00006 00007 #define LED_ON 1 00008 #define LED_OFF 0 00009 #define HT16K33_BLINK_OFF 0 00010 #define HT16K33_BLINK_2HZ 1 00011 #define HT16K33_BLINK_1HZ 2 00012 #define HT16K33_BLINK_HALFHZ 3 00013 00014 00015 /** 00016 * A class for Adafruit trellis 00017 */ 00018 class Adafruit_Trellis { 00019 public: 00020 /** 00021 * Create a new trellis object 00022 */ 00023 Adafruit_Trellis(void); 00024 00025 /** 00026 * Initialize the trellis controller 00027 * @param _wire Address of an I2C master object 00028 * @param _addr Slave address of the trellis controller 00029 */ 00030 void begin(I2C *_wire, uint8_t _addr); 00031 00032 /** 00033 * Set brightness(PWM) of LEDs 00034 * @param b Brightness level from 1 to 16 with 16 being the brightest 00035 */ 00036 void setBrightness(uint8_t b); 00037 00038 /** 00039 * Set blink rate of LEDs 00040 * @param b Blink rate defined as macros 00041 */ 00042 void blinkRate(uint8_t b); 00043 00044 /** 00045 * Write to LEDs after set and clear status of LEDs 00046 */ 00047 void writeDisplay(void); 00048 00049 /** 00050 * Set all LEDs to off 00051 */ 00052 void clear(void); 00053 00054 /** 00055 * Check status of LED 00056 * @param x LED index (1-16) 00057 * @return 1 for on, 0 for off 00058 */ 00059 bool isLED(uint8_t x); 00060 00061 /** 00062 * Set LED status to on 00063 * @param x LED index (1-16) 00064 */ 00065 void setLED(uint8_t x); 00066 00067 /** 00068 * Set LED status to off 00069 * @param x LED index (1-16) 00070 */ 00071 void clrLED(uint8_t x); 00072 00073 /** 00074 * Check if button is pressed 00075 * @param k button index (1-16) 00076 * @return 1 for pressed, 0 for not pressed 00077 */ 00078 bool isKeyPressed(uint8_t k); 00079 00080 /** 00081 * Check if button was pressed 00082 * @param k button index (1-16) 00083 * @return 1 for pressed, 0 for not pressed 00084 */ 00085 bool wasKeyPressed(uint8_t k); 00086 00087 /** 00088 * Update all buttons' status, need to be called before checking buttons' status 00089 * @return 1 for any button has been switched, 0 otherwise 00090 */ 00091 bool readSwitches(void); 00092 00093 /** 00094 * Check if button was just pressed 00095 * @param k button index (1-16) 00096 * @return 1 for pressed, 0 for not pressed 00097 */ 00098 bool justPressed(uint8_t k); 00099 00100 /** 00101 * Check if button was just released 00102 * @param k button index (1-16) 00103 * @return 1 for released, 0 for not released 00104 */ 00105 bool justReleased(uint8_t k); 00106 00107 uint16_t displaybuffer[8]; 00108 00109 void init(uint8_t a); 00110 00111 private: 00112 uint8_t keys[6], lastkeys[6]; 00113 00114 uint8_t i2c_addr; 00115 char cmd[20]; 00116 I2C *wire; 00117 };
Generated on Wed Jul 13 2022 18:58:39 by
