-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunduino.h
77 lines (67 loc) · 1.86 KB
/
Funduino.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#if !defined(FNDUINO_H)
#if !defined(ARDUINO_AVR_UNO)
#error "This library only supports Arduino Uno boards"
#endif
#define FNDUINO_H 1
#define FUNDUI_DISPLATCH 4
#define FUNDUI_DISPCLOCK 7
#define FUNDUI_DISPDATA 8
#define FUNDUI_BUTT1 A1
#define FUNDUI_BUTT2 A2
#define FUNDUI_BUTT3 A3
#define FUNDUI_LED1 13
#define FUNDUI_LED2 12
#define FUNDUI_LED3 11
#define FUNDUI_LED4 10
#define FUNDUI_SERVO1 5
#define FUNDUI_SERVO2 6
#define FUNDUI_SERVO3 9
#define FUNDUI_SERVO4 A5
#define FUNDUI_BUZZER 3
#define FUNDUI_TRIMMER A0
#define FUNDUI_CONN7A 2
#define FUNDUI_CONN7B A4
class Funduino {
public:
static int divmod10(int *i);
static float mapf(float x, float a, float b, float c, float d);
static const unsigned char DisTable[16];
// data pro segmentovky
unsigned char disbuff[4];
long Mili;
void step();
Funduino();
void begin();
void enableDisplay(bool ena=true);
void segment(byte segs, byte digit=0);
void clearDisplay();
float trimVolt();
void dispDigit(byte val, byte pos, bool digit = true);
void dispInt(int val,byte fmt=DEC,byte minchars=1);
void dispFloat(float val);
void display(float val);
void display(double val);
void display(int val);
bool butt1();
bool butt2();
bool butt3();
bool butt(byte button);
byte buttons();
void timerStart(byte i, int time, bool repeat=true);
inline void timerStop(byte i) {timerStart(i,0,false);}
int timerTime(byte i);
bool isTimer(byte i);
bool buttPressed(byte i);
bool buttReleased(byte i);
inline void led(byte i,bool on=true) {
digitalWrite(
i==2?FUNDUI_LED2:(i==3?FUNDUI_LED3:(i==4?FUNDUI_LED4:FUNDUI_LED1))
,on?LOW:HIGH); }
private:
byte _enables,_flags,_butstate,_timtrig,_buttrig;
unsigned int _timers_start[11]={}, /* 8 timers + 3 buttons */
_timers_togo[11]={},
_timers_repeat[8]={},
_mimi;
};
#endif