diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-02-01 20:59:22 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-02-01 20:59:24 +0530 |
| commit | 8fa32bb0414c3164d8c3467c5db4c1a912627fc4 (patch) | |
| tree | 0d1c3b5f1aa27f77b4678b6f65f38b8b09dfce37 /src | |
| parent | 7224fce49e4fa8c0b966dcc8d4f9b1d12b02f66a (diff) | |
| download | daft-watch-8fa32bb0414c3164d8c3467c5db4c1a912627fc4.tar.gz daft-watch-8fa32bb0414c3164d8c3467c5db4c1a912627fc4.zip | |
Remove platformio stuff and switch to avr-gcc
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 50 | ||||
| -rw-r--r-- | src/main.cpp | 16 |
2 files changed, 50 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..a7e2646 --- /dev/null +++ b/src/main.c @@ -0,0 +1,50 @@ +#include <avr/io.h> +#include <util/delay.h> + +// gfedcba +const long digits[] = { + 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, + 0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111, +}; + +// a, b, c, d, e, f, g +const int segment_pins[] = {4, 5, 6, 7, 8, 9, 10}; + +void write_digit(int digit) { + if (digit > 9 || digit < 0) + return; + + long mask = digits[digit]; + for (int i = 0; i < 7; i++) { + short on = 0 != (mask & (i == 0 ? 1 : 2 << (i - 1))); + // digitalWrite(segment_pins[i], on); + } +} + +void setup(void) { + for (int i = 0; i < 7; i++) { + int pin = segment_pins[i]; + DDRA |= (1 << PA1); + } +} + +int i = 0; +void loop(void) { + write_digit(i); + _delay_ms(500); + i = (i + 1) % 10; +} + +int main(void) { + setup(); + + while (1) { + loop(); + // PORTA |= (1 << PA1); + // _delay_ms(500); + // PORTA &= ~(1 << PA1); + // _delay_ms(500); + } + + return 0; +} diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 6226244..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include <Arduino.h> - -// Physical Pin 2 on the ATtiny84a is Arduino Digital Pin 0 -#define LED_PIN 0 - -void setup() { - // Initialize the digital pin as an output. - pinMode(LED_PIN, OUTPUT); -} - -void loop() { - digitalWrite(LED_PIN, HIGH); // Turn the LED on - delay(1000); // Wait for a second - digitalWrite(LED_PIN, LOW); // Turn the LED off - delay(1000); // Wait for a second -} |
