Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added brightness control and blink()
  • Loading branch information
ladyada committed Nov 8, 2011
1 parent 56176ed commit 94a6f3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
19 changes: 19 additions & 0 deletions HT1632.cpp
Expand Up @@ -36,6 +36,17 @@ void HT1632::begin(uint8_t type) {
HEIGHT = 16;
}

void HT1632::setBrightness(uint8_t pwm) {
if (pwm > 15) pwm = 15;
sendcommand(HT1632_PWM_CONTROL | pwm);
}

void HT1632::blink(boolean blinky) {
if (blinky)
sendcommand(HT1632_BLINK_ON);
else
sendcommand(HT1632_BLINK_OFF);
}

void HT1632::clrPixel(uint8_t x, uint8_t y) {
ledmatrix[(y*WIDTH+x) / 8] &= ~_BV(7 - (y*WIDTH+x) % 8);
Expand All @@ -45,6 +56,14 @@ void HT1632::setPixel(uint8_t x, uint8_t y) {
ledmatrix[(y*WIDTH+x) / 8] |= _BV(7 - (y*WIDTH+x) % 8);
}

void HT1632::setPixel(uint16_t i) {
ledmatrix[i/8] |= _BV(i%8);
}

void HT1632::clrPixel(uint16_t i) {
ledmatrix[i/8] &= ~_BV(i%8);
}

void HT1632::dumpScreen() {
Serial.println("---------------------------------------");
for (uint16_t i=0; i<(WIDTH*HEIGHT/8); i++) {
Expand Down
14 changes: 7 additions & 7 deletions HT1632.h
Expand Up @@ -32,17 +32,17 @@ class HT1632 {
void clrPixel(uint8_t x, uint8_t y);
void setPixel(uint8_t x, uint8_t y);

void clrPixel(uint16_t i);
void setPixel(uint16_t i);

void blink(boolean state);
void setBrightness(uint8_t pwm);

void clearScreen();
void fillScreen();
void writeScreen();
void dumpScreen();

/*
void blink(void);
void blinkOff(void);
void setBrightness(uint8_t pwm);
*/

private:
int8_t WIDTH, HEIGHT;
int8_t _data, _cs, _wr, _rd;
Expand Down

0 comments on commit 94a6f3d

Please sign in to comment.