Starting attiny84 porting
This commit is contained in:
		@@ -1 +1,7 @@
 | 
				
			|||||||
#include "button.hpp"
 | 
					#include "button.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <Arduino.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool Button::is_button_pressed(void) {
 | 
				
			||||||
 | 
					    return (analogRead(0) > 950);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,11 +1,10 @@
 | 
				
			|||||||
#ifndef __BUTTON_HPP__
 | 
					#ifndef __BUTTON_HPP__
 | 
				
			||||||
#define __BUTTON_HPP__
 | 
					#define __BUTTON_HPP__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "pins.hpp"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Button {
 | 
					class Button {
 | 
				
			||||||
public:
 | 
					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:
 | 
					private:
 | 
				
			||||||
	unsigned _aPin;
 | 
						unsigned _aPin;
 | 
				
			||||||
	int _vRef;
 | 
						int _vRef;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										104
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										104
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -1,52 +1,52 @@
 | 
				
			|||||||
#include <Arduino.h>
 | 
					#include <Arduino.h>
 | 
				
			||||||
#include <SoftwareSerial.h>
 | 
					#include <SoftwareSerial.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// #include "display.hpp"
 | 
					// #include "display.hpp"
 | 
				
			||||||
// #include "rotary_encoder.hpp"
 | 
					// #include "rotary_encoder.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// int seconds = 0;
 | 
					// int seconds = 0;
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// void start_count(int seconds);
 | 
					// void start_count(int seconds);
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Display display;
 | 
					// Display display;
 | 
				
			||||||
// RotaryEncoder encoder;
 | 
					// RotaryEncoder encoder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SoftwareSerial swSerial(3, 4);
 | 
					SoftwareSerial swSerial(3, 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setup() {
 | 
					void setup() {
 | 
				
			||||||
	swSerial.begin(9600);
 | 
						swSerial.begin(9600);
 | 
				
			||||||
	// display = Display();
 | 
						// display = Display();
 | 
				
			||||||
	// encoder = RotaryEncoder();
 | 
						// encoder = RotaryEncoder();
 | 
				
			||||||
	while(!swSerial.available());
 | 
						while(!swSerial.available());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	swSerial.println("nik");
 | 
						swSerial.println("nik");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void loop() {
 | 
					void loop() {
 | 
				
			||||||
	if (analogRead(0) > 950) {
 | 
						if (analogRead(0) > 950) {
 | 
				
			||||||
		swSerial.println("niki");
 | 
							swSerial.println("niki");
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		swSerial.println("pushed");
 | 
							swSerial.println("pushed");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	delay(1000);
 | 
						delay(1000);
 | 
				
			||||||
	// display.print_time(seconds);
 | 
						// display.print_time(seconds);
 | 
				
			||||||
	// seconds = encoder.value_select(display);
 | 
						// seconds = encoder.value_select(display);
 | 
				
			||||||
	// start_count(seconds);
 | 
						// start_count(seconds);
 | 
				
			||||||
	// while (analogRead(0) > 950) {
 | 
						// while (analogRead(0) > 950) {
 | 
				
			||||||
	// 	display.chenillard();
 | 
						// 	display.chenillard();
 | 
				
			||||||
	// }
 | 
						// }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// void start_count(int secondsToWait) {
 | 
					// void start_count(int secondsToWait) {
 | 
				
			||||||
// 	unsigned long millisToWait = secondsToWait * 1000L;
 | 
					// 	unsigned long millisToWait = secondsToWait * 1000L;
 | 
				
			||||||
// 	unsigned long millisElapsed = 0L;
 | 
					// 	unsigned long millisElapsed = 0L;
 | 
				
			||||||
// 	unsigned long millisAtStart = millis();
 | 
					// 	unsigned long millisAtStart = millis();
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// 	do {
 | 
					// 	do {
 | 
				
			||||||
// 		millisElapsed = millis() - millisAtStart;
 | 
					// 		millisElapsed = millis() - millisAtStart;
 | 
				
			||||||
// 		display.print_time(secondsToWait - millisElapsed / 1000);
 | 
					// 		display.print_time(secondsToWait - millisElapsed / 1000);
 | 
				
			||||||
// 		delay(500);
 | 
					// 		delay(500);
 | 
				
			||||||
// 	} while (millisElapsed < millisToWait);
 | 
					// 	} while (millisElapsed < millisToWait);
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// }
 | 
					// }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ int RotaryEncoder::value_select(Display &display) {
 | 
				
			|||||||
			_currentValue = newEncVal;
 | 
								_currentValue = newEncVal;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (-4 >= _shift || _shift >= 4) {
 | 
								if (-4 >= _shift || _shift >= 4) {
 | 
				
			||||||
 | 
									/* todo make real comp : int size is target dependant */
 | 
				
			||||||
				int sign = _shift >> 2;
 | 
									int sign = _shift >> 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (seconds < 60) {
 | 
									if (seconds < 60) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user