Skip to content

Commit

Permalink
Merge pull request #25 from Unreal-Dan/kurt/correct-sleep
Browse files Browse the repository at this point in the history
kurt/correct-sleep
  • Loading branch information
Unreal-Dan authored Jan 19, 2024
2 parents 2f86a44 + 82ecbbf commit be2a43e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
15 changes: 4 additions & 11 deletions Helios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ bool Helios::init()
#elif F_CPU == 8000000L
// 1ms at 8mhz clock with prescaler of 64
OCR0A = 124;
#elif F_CPU == 1000000L
// 1ms at 1mhz clock with prescaler of 64
OCR0A = 15; // Adjusted value for 1 MHz clock
#endif
TIMSK |= (1 << OCIE0A);
// Start timer with prescaler of 64
TCCR0B |= (1 << CS01) | (1 << CS00);
// enable interrupts
sei();
#endif

return true;
}

Expand Down Expand Up @@ -125,8 +129,6 @@ void Helios::tick()
void Helios::enter_sleep()
{
#ifdef HELIOS_EMBEDDED
// init the output pins to prevent any floating pins
clear_output_pins();
// Enable wake on interrupt for the button
Button::enableWake();
// Set sleep mode to POWER DOWN mode
Expand All @@ -143,15 +145,6 @@ void Helios::enter_sleep()
#endif
}

#ifdef HELIOS_EMBEDDED
void Helios::clear_output_pins() {
// Set all pins to output
DDRB = 0xFF;
// Set all pins low
PORTB = 0x00;
}
#endif

void Helios::wakeup() {
#ifdef HELIOS_EMBEDDED
// nothing needed here, this interrupt firing will make the mainthread resume
Expand Down
4 changes: 0 additions & 4 deletions Helios.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ class Helios
static void save_global_flags();
static void show_selection(RGBColor color);

#ifdef HELIOS_EMBEDDED
static void clear_output_pins();
#endif

enum State : uint8_t {
STATE_MODES,
STATE_COLOR_SELECT_SLOT,
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ $(TARGET).elf: $(OBJS)
%.o: %.cpp
$(CC) $(CFLAGS) -c $< -o $@

upload: $(TARGET).hex
upload: set_fuses $(TARGET).hex
$(AVRDUDE) $(AVRDUDE_FLAGS) -Uflash:w:$(TARGET).hex:i

upload_eeprom: $(TARGET).eep
Expand All @@ -155,8 +155,8 @@ install:
@echo "Download and extraction complete. You'll find the toolchain and pack files in $(INSTALL_DIR)"
endif

set_16mhz_fuses:
$(AVRDUDE) $(AVRDUDE_FLAGS) -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m
set_fuses:
$(AVRDUDE) $(AVRDUDE_FLAGS) -U lfuse:w:0xe1:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m

set_default_fuses:
$(AVRDUDE) $(AVRDUDE_FLAGS) -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
Expand Down

0 comments on commit be2a43e

Please sign in to comment.