├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── githubci.yml ├── Adafruit_HT1632.cpp ├── Adafruit_HT1632.h ├── examples ├── basicdemo │ └── basicdemo.ino ├── matrixdemo │ └── matrixdemo.ino └── matrixshapes │ └── matrixshapes.ino └── library.properties /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /.github/workflows/githubci.yml: -------------------------------------------------------------------------------- 1 | name: Arduino Library CI 2 | 3 | on: [pull_request, push, repository_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/setup-python@v4 11 | with: 12 | python-version: '3.x' 13 | - uses: actions/checkout@v3 14 | - uses: actions/checkout@v3 15 | with: 16 | repository: adafruit/ci-arduino 17 | path: ci 18 | 19 | - name: pre-install 20 | run: bash ci/actions_install.sh 21 | 22 | - name: test platforms 23 | run: python3 ci/build_platform.py main_platforms 24 | 25 | - name: clang 26 | run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . 27 | 28 | - name: doxygen 29 | env: 30 | GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 31 | PRETTYNAME : "Adafruit HT1632 Library" 32 | run: bash ci/doxy_gen_and_deploy.sh 33 | -------------------------------------------------------------------------------- /Adafruit_HT1632.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_HT1632.h 3 | * 4 | * @mainpage Adafruit HT1632 Driver 5 | * 6 | * 7 | * @section author Author 8 | * 9 | * Written by Limor Fried/Ladyada for Adafruit Industries. 10 | * 11 | * @section license License 12 | * 13 | * BSD license, all text above must be included in any redistribution 14 | */ 15 | 16 | #include "Adafruit_HT1632.h" 17 | 18 | #ifndef _swap_int16_t 19 | #define _swap_int16_t(a, b) \ 20 | { \ 21 | int16_t t = a; \ 22 | a = b; \ 23 | b = t; \ 24 | } 25 | #endif 26 | 27 | // Constructor for single GFX matrix 28 | Adafruit_HT1632LEDMatrix::Adafruit_HT1632LEDMatrix(uint8_t data, uint8_t wr, 29 | uint8_t cs1) 30 | : Adafruit_GFX(24, 16), matrices(NULL), matrixNum(0) { 31 | if ((matrices = (Adafruit_HT1632 *)malloc(sizeof(Adafruit_HT1632)))) { 32 | matrices[0] = Adafruit_HT1632(data, wr, cs1); 33 | matrixNum = 1; 34 | } 35 | } 36 | 37 | // Constructor for two matrices, tiled side-by-side for GFX 38 | Adafruit_HT1632LEDMatrix::Adafruit_HT1632LEDMatrix(uint8_t data, uint8_t wr, 39 | uint8_t cs1, uint8_t cs2) 40 | : Adafruit_GFX(48, 16), matrices(NULL), matrixNum(0) { 41 | if ((matrices = (Adafruit_HT1632 *)malloc(2 * sizeof(Adafruit_HT1632)))) { 42 | matrices[0] = Adafruit_HT1632(data, wr, cs1); 43 | matrices[1] = Adafruit_HT1632(data, wr, cs2); 44 | matrixNum = 2; 45 | } 46 | } 47 | 48 | // Constructor for three matrices, tiled side-by-side for GFX 49 | Adafruit_HT1632LEDMatrix::Adafruit_HT1632LEDMatrix(uint8_t data, uint8_t wr, 50 | uint8_t cs1, uint8_t cs2, 51 | uint8_t cs3) 52 | : Adafruit_GFX(72, 16), matrices(NULL), matrixNum(0) { 53 | if ((matrices = (Adafruit_HT1632 *)malloc(3 * sizeof(Adafruit_HT1632)))) { 54 | matrices[0] = Adafruit_HT1632(data, wr, cs1); 55 | matrices[1] = Adafruit_HT1632(data, wr, cs2); 56 | matrices[2] = Adafruit_HT1632(data, wr, cs3); 57 | matrixNum = 3; 58 | } 59 | } 60 | 61 | // Constructor for four matrices, tiled side-by-side for GFX 62 | Adafruit_HT1632LEDMatrix::Adafruit_HT1632LEDMatrix(uint8_t data, uint8_t wr, 63 | uint8_t cs1, uint8_t cs2, 64 | uint8_t cs3, uint8_t cs4) 65 | : Adafruit_GFX(96, 16), matrices(NULL), matrixNum(0) { 66 | if ((matrices = (Adafruit_HT1632 *)malloc(4 * sizeof(Adafruit_HT1632)))) { 67 | matrices[0] = Adafruit_HT1632(data, wr, cs1); 68 | matrices[1] = Adafruit_HT1632(data, wr, cs2); 69 | matrices[2] = Adafruit_HT1632(data, wr, cs3); 70 | matrices[3] = Adafruit_HT1632(data, wr, cs4); 71 | matrixNum = 4; 72 | } 73 | } 74 | 75 | void Adafruit_HT1632LEDMatrix::setPixel(uint8_t x, uint8_t y) { 76 | drawPixel(x, y, 1); 77 | } 78 | 79 | void Adafruit_HT1632LEDMatrix::clrPixel(uint8_t x, uint8_t y) { 80 | drawPixel(x, y, 0); 81 | } 82 | 83 | void Adafruit_HT1632LEDMatrix::drawPixel(int16_t x, int16_t y, uint16_t color) { 84 | if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) 85 | return; 86 | 87 | switch (rotation) { // Rotate pixel into device-specific coordinates 88 | case 1: 89 | _swap_int16_t(x, y); 90 | x = WIDTH - 1 - x; 91 | break; 92 | case 2: 93 | x = WIDTH - 1 - x; 94 | y = HEIGHT - 1 - y; 95 | break; 96 | case 3: 97 | _swap_int16_t(x, y); 98 | y = HEIGHT - 1 - y; 99 | break; 100 | } 101 | 102 | uint8_t m = x / 24; // Which matrix controller is pixel on? 103 | x %= 24; // Which column in matrix? 104 | 105 | uint16_t i; 106 | 107 | if (x < 8) 108 | i = 7; 109 | else if (x < 16) 110 | i = 128 + 7; 111 | else 112 | i = 256 + 7; 113 | i -= (x & 7); 114 | 115 | if (y < 8) 116 | y *= 2; 117 | else 118 | y = (y - 8) * 2 + 1; 119 | i += y * 8; 120 | 121 | if (color) 122 | matrices[m].setPixel(i); 123 | else 124 | matrices[m].clrPixel(i); 125 | } 126 | 127 | boolean Adafruit_HT1632LEDMatrix::begin(uint8_t type) { 128 | if (matrixNum) { // Did malloc() work OK? 129 | for (uint8_t i = 0; i < matrixNum; i++) 130 | matrices[i].begin(type); 131 | return true; 132 | } 133 | return false; 134 | } 135 | 136 | void Adafruit_HT1632LEDMatrix::clearScreen() { 137 | for (uint8_t i = 0; i < matrixNum; i++) 138 | matrices[i].clearScreen(); 139 | } 140 | 141 | void Adafruit_HT1632LEDMatrix::fillScreen() { 142 | for (uint8_t i = 0; i < matrixNum; i++) 143 | matrices[i].fillScreen(); 144 | } 145 | 146 | void Adafruit_HT1632LEDMatrix::setBrightness(uint8_t b) { 147 | for (uint8_t i = 0; i < matrixNum; i++) 148 | matrices[i].setBrightness(b); 149 | } 150 | 151 | void Adafruit_HT1632LEDMatrix::blink(boolean b) { 152 | for (uint8_t i = 0; i < matrixNum; i++) 153 | matrices[i].blink(b); 154 | } 155 | 156 | void Adafruit_HT1632LEDMatrix::writeScreen() { 157 | for (uint8_t i = 0; i < matrixNum; i++) 158 | matrices[i].writeScreen(); 159 | } 160 | 161 | ////////////////////////////////////////////////////////////////////////// 162 | 163 | Adafruit_HT1632::Adafruit_HT1632(int8_t data, int8_t wr, int8_t cs, int8_t rd) { 164 | _data = data; 165 | _wr = wr; 166 | _cs = cs; 167 | _rd = rd; 168 | memset(ledmatrix, 0, sizeof(ledmatrix)); 169 | } 170 | 171 | void Adafruit_HT1632::begin(uint8_t type) { 172 | pinMode(_cs, OUTPUT); 173 | digitalWrite(_cs, HIGH); 174 | pinMode(_wr, OUTPUT); 175 | digitalWrite(_wr, HIGH); 176 | pinMode(_data, OUTPUT); 177 | 178 | if (_rd >= 0) { 179 | pinMode(_rd, OUTPUT); 180 | digitalWrite(_rd, HIGH); 181 | } 182 | 183 | #ifdef __AVR__ 184 | csport = portOutputRegister(digitalPinToPort(_cs)); 185 | csmask = digitalPinToBitMask(_cs); 186 | wrport = portOutputRegister(digitalPinToPort(_wr)); 187 | wrmask = digitalPinToBitMask(_wr); 188 | dataport = portOutputRegister(digitalPinToPort(_data)); 189 | datadir = portModeRegister(digitalPinToPort(_data)); 190 | datamask = digitalPinToBitMask(_data); 191 | #endif 192 | 193 | sendcommand(ADA_HT1632_SYS_EN); 194 | sendcommand(ADA_HT1632_LED_ON); 195 | sendcommand(ADA_HT1632_BLINK_OFF); 196 | sendcommand(ADA_HT1632_MASTER_MODE); 197 | sendcommand(ADA_HT1632_INT_RC); 198 | sendcommand(type); 199 | sendcommand(ADA_HT1632_PWM_CONTROL | 0xF); 200 | } 201 | 202 | void Adafruit_HT1632::setBrightness(uint8_t pwm) { 203 | if (pwm > 15) 204 | pwm = 15; 205 | sendcommand(ADA_HT1632_PWM_CONTROL | pwm); 206 | } 207 | 208 | void Adafruit_HT1632::blink(boolean blinky) { 209 | sendcommand(blinky ? ADA_HT1632_BLINK_ON : ADA_HT1632_BLINK_OFF); 210 | } 211 | 212 | void Adafruit_HT1632::setPixel(uint16_t i) { 213 | ledmatrix[i / 8] |= (1 << (i & 7)); 214 | } 215 | 216 | void Adafruit_HT1632::clrPixel(uint16_t i) { 217 | ledmatrix[i / 8] &= ~(1 << (i & 7)); 218 | } 219 | 220 | void Adafruit_HT1632::dumpScreen() { 221 | Serial.println(F("---------------------------------------")); 222 | 223 | for (uint16_t i = 0; i < sizeof(ledmatrix); i++) { 224 | Serial.print("0x"); 225 | Serial.print(ledmatrix[i], HEX); 226 | Serial.print(" "); 227 | if (i % 3 == 2) 228 | Serial.println(); 229 | } 230 | 231 | Serial.println(F("\n---------------------------------------")); 232 | } 233 | 234 | void Adafruit_HT1632::writeScreen() { 235 | 236 | #ifdef __AVR__ 237 | *csport &= ~csmask; 238 | *datadir |= datamask; // OUTPUT 239 | #else 240 | digitalWrite(_cs, LOW); 241 | #endif 242 | 243 | writedata(ADA_HT1632_WRITE, 3); 244 | // send with address 0 245 | writedata(0, 7); 246 | 247 | for (uint16_t i = 0; i < sizeof(ledmatrix); i += 2) { 248 | writedata(((uint16_t)ledmatrix[i] << 8) | ledmatrix[i + 1], 16); 249 | } 250 | 251 | #ifdef __AVR__ 252 | *csport |= csmask; 253 | *datadir &= ~datamask; // INPUT 254 | #else 255 | digitalWrite(_cs, HIGH); 256 | #endif 257 | } 258 | 259 | void Adafruit_HT1632::clearScreen() { 260 | memset(ledmatrix, 0, sizeof(ledmatrix)); 261 | writeScreen(); 262 | } 263 | 264 | void Adafruit_HT1632::writedata(uint16_t d, uint8_t bits) { 265 | #ifdef __AVR__ 266 | for (uint16_t bit = 1 << (bits - 1); bit; bit >>= 1) { 267 | *wrport &= ~wrmask; 268 | if (d & bit) 269 | *dataport |= datamask; 270 | else 271 | *dataport &= ~datamask; 272 | *wrport |= wrmask; 273 | } 274 | #else 275 | pinMode(_data, OUTPUT); 276 | for (uint16_t bit = 1 << (bits - 1); bit; bit >>= 1) { 277 | digitalWrite(_wr, LOW); 278 | digitalWrite(_data, (d & bit) ? HIGH : LOW); 279 | digitalWrite(_wr, HIGH); 280 | } 281 | pinMode(_data, INPUT); 282 | #endif 283 | } 284 | 285 | void Adafruit_HT1632::writeRAM(uint8_t addr, uint8_t data) { 286 | // Serial.print("Writing 0x"); Serial.print(data&0xF, HEX); 287 | // Serial.print(" to 0x"); Serial.println(addr & 0x7F, HEX); 288 | 289 | uint16_t d = ADA_HT1632_WRITE; 290 | d <<= 7; 291 | d |= addr & 0x7F; 292 | d <<= 4; 293 | d |= data & 0xF; 294 | 295 | #ifdef __AVR__ 296 | *csport &= ~csmask; 297 | writedata(d, 14); 298 | *csport |= csmask; 299 | #else 300 | digitalWrite(_cs, LOW); 301 | writedata(d, 14); 302 | digitalWrite(_cs, HIGH); 303 | #endif 304 | } 305 | 306 | void Adafruit_HT1632::sendcommand(uint8_t cmd) { 307 | #ifdef __AVR__ 308 | *csport &= ~csmask; 309 | *datadir |= datamask; // OUTPUT 310 | writedata((((uint16_t)ADA_HT1632_COMMAND << 8) | cmd) << 1, 12); 311 | *datadir &= ~datamask; // INPUT 312 | *csport |= csmask; 313 | #else 314 | digitalWrite(_cs, LOW); 315 | writedata((((uint16_t)ADA_HT1632_COMMAND << 8) | cmd) << 1, 12); 316 | digitalWrite(_cs, HIGH); 317 | #endif 318 | } 319 | 320 | void Adafruit_HT1632::fillScreen() { 321 | memset(ledmatrix, 0xFF, sizeof(ledmatrix)); 322 | writeScreen(); 323 | } 324 | -------------------------------------------------------------------------------- /Adafruit_HT1632.h: -------------------------------------------------------------------------------- 1 | #include "Adafruit_GFX.h" 2 | 3 | #ifndef ADA_HT1632_H_ 4 | #define ADA_HT1632_H_ 5 | 6 | #if (ARDUINO >= 100) 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #define ADA_HT1632_READ 0x06 //!< Read data from the RAM 13 | #define ADA_HT1632_WRITE 0x05 //!< Write data to the RAM 14 | #define ADA_HT1632_COMMAND 0x04 //!< Send command 15 | 16 | #define ADA_HT1632_SYS_DIS \ 17 | 0x00 //!< Stops system clock, turns off LED duty cycle generator, reducing 18 | //!< power usage 19 | #define ADA_HT1632_SYS_EN 0x01 //!< Turn on system oscillator 20 | #define ADA_HT1632_LED_OFF 0x02 //!< Turn off LED duty cycle generator 21 | #define ADA_HT1632_LED_ON 0x03 //!< Turn on LED duty cycle generator 22 | #define ADA_HT1632_BLINK_OFF 0x08 //!< Turn off blinking function 23 | #define ADA_HT1632_BLINK_ON 0x09 //!< Turn on blinking function 24 | #define ADA_HT1632_SLAVE_MODE \ 25 | 0x10 //!< Set slave mode and clock source from external clock 26 | #define ADA_HT1632_MASTER_MODE \ 27 | 0x14 //!< Set master mode and clock source from on-chip RC oscillator 28 | #define ADA_HT1632_INT_RC 0x18 //!< Use internal RC oscillator 29 | #define ADA_HT1632_EXT_CLK \ 30 | 0x1C //!< Set master mode and clock source from external clock 31 | #define ADA_HT1632_PWM_CONTROL 0xA0 //!< PWM brightness control 32 | 33 | #define ADA_HT1632_COMMON_8NMOS \ 34 | 0x20 //!< NMOS open drain output driver for commons 35 | #define ADA_HT1632_COMMON_16NMOS \ 36 | 0x24 //!< NMOS open drain output driver for commons 37 | #define ADA_HT1632_COMMON_8PMOS \ 38 | 0x28 //!< PMOS open drain output driver for commons 39 | #define ADA_HT1632_COMMON_16PMOS \ 40 | 0x2C //!< PMOS open drain output driver for commons 41 | 42 | /*! 43 | * @brief Driver for the Adafruit HT1632 LED matrix driver 44 | */ 45 | class Adafruit_HT1632 { 46 | 47 | public: 48 | /*! 49 | * @brief LED matrix object 50 | * @param data Serial data input or output with high-pull resistor 51 | * @param wr WRITE clock input with pull-high resistor. 52 | * @param cs Chip select 53 | * @param rd Read block input 54 | */ 55 | Adafruit_HT1632(int8_t data, int8_t wr, int8_t cs, int8_t rd = -1); 56 | 57 | /*! 58 | * @brief Initialize driver 59 | * @param type Matrix type 60 | * @return Returns whether or not the initialization was successful 61 | */ 62 | void begin(uint8_t type), 63 | /*! 64 | * @brief Clears a specific pixel 65 | * @param i Pixel to clear 66 | */ 67 | clrPixel(uint16_t i), 68 | /*! 69 | * @brief Sets a specific pixel 70 | * @param i Pixel to set 71 | */ 72 | setPixel(uint16_t i), 73 | /*! 74 | * @brief Turn display on with or without blinking 75 | * @param state Whether or not to blink when turning on the display 76 | */ 77 | blink(boolean state), 78 | /*! 79 | * @brief Sets screen brightness 80 | * @param pwm Desired brightness 81 | */ 82 | setBrightness(uint8_t pwm), 83 | /*! Clears the screen */ 84 | clearScreen(), 85 | /*! Fills the screen */ 86 | fillScreen(), 87 | /*! Writes to the screen */ 88 | writeScreen(), 89 | /*! Dumps the screen */ 90 | dumpScreen(); 91 | 92 | protected: 93 | /** 94 | * _data private serial data output 95 | * _cs private chip select input 96 | * _wr private WRITE clock input 97 | * _rd private READ clock input with high-pull resistor 98 | *@{ 99 | */ 100 | int8_t _data, _cs, _wr, _rd; 101 | /** @}*/ 102 | uint8_t ledmatrix[24 * 16 / 8]; //!< LED matrix size 103 | /*! 104 | * @brief Sends command to HT1632 105 | * @param c Command to send 106 | */ 107 | void sendcommand(uint8_t c), 108 | /*! 109 | * @brief Writes data to the driver 110 | * @param d Write address 111 | * @param bits Bits to write 112 | */ 113 | writedata(uint16_t d, uint8_t bits), 114 | /*! 115 | * @brief Writes RAM to the driver 116 | * @param addr Address to write to 117 | * @param data Data to write 118 | */ 119 | writeRAM(uint8_t addr, uint8_t data); 120 | #ifdef __AVR__ 121 | volatile uint8_t *dataport, *csport, *wrport, *datadir; 122 | uint8_t datamask, csmask, wrmask; 123 | #endif 124 | }; 125 | 126 | /*! 127 | * HT1632LEDMatrix main class 128 | */ 129 | class Adafruit_HT1632LEDMatrix : public Adafruit_GFX { 130 | public: 131 | /*! 132 | * @brief LED matrix function for 1 matrix 133 | * @param data Serial data input or output with high-pull resistor 134 | * @param wr WRITE clock input with pull-high resistor. 135 | * @param cs1 Chip select input 1 136 | */ 137 | Adafruit_HT1632LEDMatrix(uint8_t data, uint8_t wr, uint8_t cs1); 138 | /*! 139 | * @brief LED matrix function for 2 matrixes 140 | * @param data Serial data input or output with high-pull resistor 141 | * @param wr WRITE clock input with pull-high resistor. 142 | * @param cs1 Chip select input 1 143 | * @param cs2 Chip select input 2 144 | */ 145 | Adafruit_HT1632LEDMatrix(uint8_t data, uint8_t wr, uint8_t cs1, uint8_t cs2); 146 | /*! 147 | * @brief LED matrix function for 3 matrixes 148 | * @param data Serial data input or output with high-pull resistor 149 | * @param wr WRITE clock input with pull-high resistor. 150 | * @param cs1 Chip select input 1 151 | * @param cs Chip select input 2 152 | * @param cs3 Chip select input 3 153 | */ 154 | Adafruit_HT1632LEDMatrix(uint8_t data, uint8_t wr, uint8_t cs1, uint8_t cs, 155 | uint8_t cs3); 156 | /*! 157 | * @brief LED matrix function for 4 matrixes 158 | * @param data Serial data input or output with high-pull resistor 159 | * @param wr WRITE clock input with pull-high resistor. 160 | * @param cs1 Chip select input 1 161 | * @param cs2 Chip select input 2 162 | * @param cs3 Chip select input 3 163 | * @param cs4 Chip select input 4 164 | */ 165 | Adafruit_HT1632LEDMatrix(uint8_t data, uint8_t wr, uint8_t cs1, uint8_t cs2, 166 | uint8_t cs3, uint8_t cs4); 167 | 168 | /*! 169 | * @brief Initialize driver 170 | * @param type Matrix type 171 | * @return Returns whether or not the initialization was successful 172 | */ 173 | boolean begin(uint8_t type); 174 | /*! 175 | * @brief Clears the screen 176 | */ 177 | void clearScreen(void), 178 | /*! 179 | * @brief Fills the screen 180 | */ 181 | fillScreen(void), 182 | /*! 183 | * @brief Turn display on with or without blinking 184 | * @param b Whether or not to blink when turning on the display 185 | */ 186 | blink(boolean b), 187 | /*! 188 | * @brief Sets screen brightness 189 | * @param brightness Desired brightness 190 | */ 191 | setBrightness(uint8_t brightness), 192 | /*! 193 | * @brief Writes to the screen 194 | */ 195 | writeScreen(), 196 | /*! 197 | * @brief Clears specified pixel 198 | * @param x X value of specified pixel 199 | * @param y Y value of specified pixel 200 | */ 201 | clrPixel(uint8_t x, uint8_t y), 202 | /*! 203 | * @brief Turns on specified pixel 204 | * @param x X value of specified pixel 205 | * @param y Y value of specified pixel 206 | */ 207 | setPixel(uint8_t x, uint8_t y), 208 | /*! 209 | * @brief Sets specified pixel with specified color 210 | * @param x X value of desired pixel 211 | * @param y Y value of desired pixel 212 | * @param color color to draw to pixel 213 | */ 214 | drawPixel(int16_t x, int16_t y, uint16_t color); 215 | 216 | protected: 217 | Adafruit_HT1632 *matrices; //!< Matrix pointer 218 | uint8_t matrixNum; //!< The matrix's number 219 | }; 220 | 221 | #endif /* Adafruit HT1632_H_ */ 222 | -------------------------------------------------------------------------------- /examples/basicdemo/basicdemo.ino: -------------------------------------------------------------------------------- 1 | #include "Adafruit_GFX.h" 2 | #include "Adafruit_HT1632.h" 3 | 4 | /* 5 | This is a basic demo program showing how to write to a HT1632 6 | These can be used for up to 16x24 LED matrix grids, with internal memory 7 | and using only 3 pins - data, write and select. 8 | Multiple HT1632's can share data and write pins, but need unique CS pins. 9 | */ 10 | 11 | #define HT_DATA 2 12 | #define HT_WR 3 13 | #define HT_CS 4 14 | 15 | Adafruit_HT1632 matrix = Adafruit_HT1632(HT_DATA, HT_WR, HT_CS); 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | matrix.begin(ADA_HT1632_COMMON_16NMOS); 20 | 21 | delay(100); 22 | matrix.clearScreen(); 23 | } 24 | 25 | void testMatrix(Adafruit_HT1632 matrix) { 26 | for (int i=0; i<24*16; i++) { 27 | matrix.setPixel(i); 28 | matrix.writeScreen(); 29 | } 30 | 31 | // blink! 32 | matrix.blink(true); 33 | delay(2000); 34 | matrix.blink(false); 35 | 36 | // Adjust the brightness down 37 | for (int8_t i=15; i>=0; i--) { 38 | matrix.setBrightness(i); 39 | delay(100); 40 | } 41 | // then back up 42 | for (uint8_t i=0; i<16; i++) { 43 | matrix.setBrightness(i); 44 | delay(100); 45 | } 46 | 47 | // Clear it out 48 | for (int i=0; i<24*16; i++) { 49 | matrix.clrPixel(i); 50 | matrix.writeScreen(); 51 | } 52 | } 53 | 54 | void loop() { 55 | testMatrix(matrix); 56 | } 57 | -------------------------------------------------------------------------------- /examples/matrixdemo/matrixdemo.ino: -------------------------------------------------------------------------------- 1 | #include "Adafruit_HT1632.h" 2 | 3 | #define HT_DATA 2 4 | #define HT_WR 3 5 | #define HT_CS 4 6 | #define HT_CS2 5 7 | 8 | // use this line for single matrix 9 | Adafruit_HT1632LEDMatrix matrix = Adafruit_HT1632LEDMatrix(HT_DATA, HT_WR, HT_CS); 10 | // use this line for two matrices! 11 | //Adafruit_HT1632LEDMatrix matrix = Adafruit_HT1632LEDMatrix(HT_DATA, HT_WR, HT_CS, HT_CS2); 12 | 13 | void setup() { 14 | Serial.begin(9600); 15 | matrix.begin(ADA_HT1632_COMMON_16NMOS); 16 | matrix.fillScreen(); 17 | delay(500); 18 | matrix.clearScreen(); 19 | matrix.setTextWrap(false); 20 | } 21 | 22 | void loop() { 23 | 24 | 25 | for(uint8_t i=0; i<4; i++) { 26 | matrix.setRotation(i); 27 | matrix.clearScreen(); 28 | matrix.setCursor(0, 0); 29 | matrix.print("Hello"); 30 | matrix.writeScreen(); 31 | delay(1000); 32 | 33 | for (uint8_t y=0; y=0; i--) { 46 | matrix.setBrightness(i); 47 | delay(100); 48 | } 49 | // then back up 50 | for (uint8_t i=0; i<16; i++) { 51 | matrix.setBrightness(i); 52 | delay(100); 53 | } 54 | 55 | for (uint8_t y=0; y 5 | sentence=Arduino library code for HT1632(C) matrix panel driver chips, and the panels we have in the Adafruit shop 6 | paragraph=Arduino library code for HT1632(C) matrix panel driver chips, and the panels we have in the Adafruit shop 7 | category=Display 8 | url=https://github.com/adafruit/HT1632 9 | architectures=* 10 | depends=Adafruit GFX Library 11 | --------------------------------------------------------------------------------