-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.h
120 lines (95 loc) · 3.73 KB
/
Program.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
Copyright (C) 2011-2012 William Brodie-Tyrrell
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef _PROGRAM_H_
#define _PROGRAM_H_
#include <Arduino.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include "Paper.h"
#include "LEDDriver.h"
/**
* Definition of a program of exposures
*/
class Program {
static const int INVALID=0x0000;
static const int SLOTBITS=7; // Allocates 128 bytes per slot
static const int SLOTBASE=0x80;
static const int TEXTLEN=18;
static const long MAXMS=999999L; // ceiling of 1000s
public:
static const int MAXSTEPS=8;
static const int MAXEXPOSURES=MAXSTEPS * 2;
static const int FIRSTSLOT=1;
static const int LASTSLOT=7;
/// a single exposure step
class Step {
public:
/// render the step settings to the screen (time and text)
/// @param lin also display linear time (millis)
void display(LiquidCrystal &disp, char *buf, bool lin);
/// rended only the time line (bottom row);
void displayTime(LiquidCrystal &disp, char *buf, bool lin);
void displayGrade(LiquidCrystal &disp, char *buf, bool lin);
int stops; // fixed-point, 1/100ths of a stop
unsigned char grade; // grade, ISO Exposure Scale
char text[TEXTLEN+1]; // description (only TEXTLEN(18) bytes written to EEPROM)
};
class Exposure {
public:
/// render the exposure settings to the screen (time and text)
/// @param lin also display linear time (millis)
void display(LiquidCrystal &disp, char *buf, bool lin);
/// rended only the time line (bottom row);
void displayTime(LiquidCrystal &disp, char *buf, bool lin);
void displayGrade(LiquidCrystal &disp, char *buf, bool lin);
unsigned long ms; // milliseconds to expose (post-compilation, not saved)
unsigned char hardpower; //power for hard step, 0 is full, 255 is off
unsigned char softpower; //power for soft step, 0 is full, 255 is off
Step* step;
};
/// clear all entries, leaving base exposure of 0 stops
void clear();
void clearExposures();
/// step accessor
Step &getStep(int which);
Exposure &getExposure(int which);
/// determine number of valid exposure objects; first = base
// unsigned char getCount();
/// convert a program from stops to linear time so that it can be execed
bool compile(char dd, bool sg, Paper& p);
/// save to EEPROM
/// @param slot slot-number in 1..7
void save(int slot);
/// load from EEPROM
/// @param slot slot-number in 1..7
bool load(int slot);
/// configure the program as a test strip;
/// is assumed to compile after this.
void configureStrip(int base, int step, bool cover, unsigned char grade, Paper& p);
private:
int slotAddr(int slot);
void compileStripIndiv(char dd, Paper& p);
void compileStripCover(char dd, Paper& p);
bool compileNormal(char dd, bool sg, Paper& p);
void clipExposures();
/// convert hundredths-of-stops to milliseconds
static unsigned long hunToMillis(int hunst);
// compilation settings
bool isstrip, cover;
/// first step is base, rest as dodges/burns
Step steps[MAXSTEPS];
Exposure exposures[MAXEXPOSURES];
};
#endif