Starting attiny84 porting

This commit is contained in:
Tropicananass 2020-03-08 23:33:53 +01:00
parent 6c8e3f8c4a
commit 62c2b2af07
4 changed files with 61 additions and 55 deletions

View File

@ -1 +1,7 @@
#include "button.hpp"
#include <Arduino.h>
bool Button::is_button_pressed(void) {
return (analogRead(0) > 950);
}

View File

@ -1,11 +1,10 @@
#ifndef __BUTTON_HPP__
#define __BUTTON_HPP__
#include "pins.hpp"
class Button {
public:
Button(unsigned analogPin = BTN_ANALOGPIN, int vRef = BTN_VREF) : _aPin{analogPin}, _vRef{vRef} {};
Button(unsigned analogPin, int vRef) : _aPin{analogPin}, _vRef{vRef} {};
bool is_button_pressed(void);
private:
unsigned _aPin;
int _vRef;

View File

@ -1,52 +1,52 @@
#include <Arduino.h>
#include <SoftwareSerial.h>
// #include "display.hpp"
// #include "rotary_encoder.hpp"
// int seconds = 0;
//
// void start_count(int seconds);
//
// Display display;
// RotaryEncoder encoder;
SoftwareSerial swSerial(3, 4);
void setup() {
swSerial.begin(9600);
// display = Display();
// encoder = RotaryEncoder();
while(!swSerial.available());
swSerial.println("nik");
}
void loop() {
if (analogRead(0) > 950) {
swSerial.println("niki");
} else {
swSerial.println("pushed");
}
delay(1000);
// display.print_time(seconds);
// seconds = encoder.value_select(display);
// start_count(seconds);
// while (analogRead(0) > 950) {
// display.chenillard();
// }
}
// void start_count(int secondsToWait) {
// unsigned long millisToWait = secondsToWait * 1000L;
// unsigned long millisElapsed = 0L;
// unsigned long millisAtStart = millis();
//
// do {
// millisElapsed = millis() - millisAtStart;
// display.print_time(secondsToWait - millisElapsed / 1000);
// delay(500);
// } while (millisElapsed < millisToWait);
//
//
// }
#include <Arduino.h>
#include <SoftwareSerial.h>
// #include "display.hpp"
// #include "rotary_encoder.hpp"
// int seconds = 0;
//
// void start_count(int seconds);
//
// Display display;
// RotaryEncoder encoder;
SoftwareSerial swSerial(3, 4);
void setup() {
swSerial.begin(9600);
// display = Display();
// encoder = RotaryEncoder();
while(!swSerial.available());
swSerial.println("nik");
}
void loop() {
if (analogRead(0) > 950) {
swSerial.println("niki");
} else {
swSerial.println("pushed");
}
delay(1000);
// display.print_time(seconds);
// seconds = encoder.value_select(display);
// start_count(seconds);
// while (analogRead(0) > 950) {
// display.chenillard();
// }
}
// void start_count(int secondsToWait) {
// unsigned long millisToWait = secondsToWait * 1000L;
// unsigned long millisElapsed = 0L;
// unsigned long millisAtStart = millis();
//
// do {
// millisElapsed = millis() - millisAtStart;
// display.print_time(secondsToWait - millisElapsed / 1000);
// delay(500);
// } while (millisElapsed < millisToWait);
//
//
// }

View File

@ -12,6 +12,7 @@ int RotaryEncoder::value_select(Display &display) {
_currentValue = newEncVal;
if (-4 >= _shift || _shift >= 4) {
/* todo make real comp : int size is target dependant */
int sign = _shift >> 2;
if (seconds < 60) {