Skip to content

Commit

Permalink
flashlight mode
Browse files Browse the repository at this point in the history
- hold up button when powering on
  • Loading branch information
joshgoebel committed Feb 13, 2016
1 parent 31ec05f commit 363da44
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions Arduboy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ void Arduboy::begin()
{
boot(); // required

// flashlight
if(pressed(UP_BUTTON)) {
sendLCDCommand(OLED_ALL_PIXELS_ON); // smaller than allPixelsOn()
while(true) {}
}

// Audio
tunes.initChannel(PIN_SPEAKER_1);
tunes.initChannel(PIN_SPEAKER_2);
Expand Down
9 changes: 0 additions & 9 deletions core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,29 +250,20 @@ void ArduboyCore::sendLCDCommand(uint8_t command)
LCDDataMode();
}

#define OLED_PIXELS_INVERTED 0xA7 // All pixels inverted
#define OLED_PIXELS_NORMAL 0xA6 // All pixels normal

// invert the display or set to normal
// when inverted, a pixel set to 0 will be on
void ArduboyCore::invert(boolean inverse)
{
sendLCDCommand(inverse ? OLED_PIXELS_INVERTED : OLED_PIXELS_NORMAL);
}

#define OLED_ALL_PIXELS_ON 0xA5 // all pixels on
#define OLED_PIXELS_FROM_RAM 0xA4 // pixels mapped to display RAM contents

// turn all display pixels on, ignoring buffer contents
// or set to normal buffer display
void ArduboyCore::allPixelsOn(boolean on)
{
sendLCDCommand(on ? OLED_ALL_PIXELS_ON : OLED_PIXELS_FROM_RAM);
}

#define OLED_VERTICAL_FLIPPED 0xC0 // reversed COM scan direction
#define OLED_VERTICAL_NORMAL 0xC8 // normal COM scan direction

// flip the display vertically or set to normal
void ArduboyCore::flipVertical(boolean flipped)
{
Expand Down
13 changes: 13 additions & 0 deletions core.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@

#endif

// OLED hardware (SSD1306)

#define OLED_PIXELS_INVERTED 0xA7 // All pixels inverted
#define OLED_PIXELS_NORMAL 0xA6 // All pixels normal

#define OLED_ALL_PIXELS_ON 0xA5 // all pixels on
#define OLED_PIXELS_FROM_RAM 0xA4 // pixels mapped to display RAM contents

#define OLED_VERTICAL_FLIPPED 0xC0 // reversed COM scan direction
#define OLED_VERTICAL_NORMAL 0xC8 // normal COM scan direction

// -----

#define COLUMN_ADDRESS_END (WIDTH - 1) & 0x7F // 128 pixels wide
#define PAGE_ADDRESS_END ((HEIGHT/8)-1) & 0x07 // 8 pages high

Expand Down

0 comments on commit 363da44

Please sign in to comment.