Skip to content

Commit

Permalink
lib: set extension header pins to input on startup (closes #50) (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
and3rson authored Mar 25, 2024
1 parent 48c443d commit 633b80e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdk/lib/lilka/src/lilka.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace lilka {
void begin() {
serial_begin();
multiboot.begin();
ext_begin();
spi_begin();
buzzer.begin(); // Play notification sound
audio.begin();
Expand Down
1 change: 1 addition & 0 deletions sdk/lib/lilka/src/lilka.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "lilka/resources.h"
#include "lilka/fmath.h"
#include "lilka/audio.h"
#include "lilka/ext.h"

namespace lilka {
/// Ініціалізація Лілки
Expand Down
2 changes: 2 additions & 0 deletions sdk/lib/lilka/src/lilka/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
# define LILKA_P6 14 // ADC2, CH3
# define LILKA_P7 13 // ADC2, CH2
# define LILKA_P8 12 // ADC2, CH1
# define LILKA_EXT_PINS \
{ LILKA_P3, LILKA_P4, LILKA_P5, LILKA_P6, LILKA_P7, LILKA_P8 }

#else
# error "LILKA_VERSION is not defined - did you forget to set board to lilka_v2 in your platformio.ini?"
Expand Down
16 changes: 16 additions & 0 deletions sdk/lib/lilka/src/lilka/ext.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <initializer_list>
#include <Arduino.h>

#include "ext.h"
#include "config.h"

namespace lilka {

void ext_begin() {
// Iterate over the pins, set them as inputs
for (int pin : LILKA_EXT_PINS) {
pinMode(pin, INPUT);
}
}

} // namespace lilka
7 changes: 7 additions & 0 deletions sdk/lib/lilka/src/lilka/ext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

namespace lilka {

void ext_begin();

} // namespace lilka

0 comments on commit 633b80e

Please sign in to comment.