-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcarvin.h
82 lines (57 loc) · 2.56 KB
/
carvin.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
/*
carvin.h - Handles Carvin Controller specific items
Copyright (c) 2014,2015 Bart Dring / Inventables
*/
#ifndef carvin_h
#define carvin_h
// Note Carvin uses Mega 2560 resources (timers, PWM) so it cannot run on UNO hardware
#define BUTTON_UP_WAIT_TIME 6000
#define OFF_BUTTON_COUNT 1000 // about 2 seconds
// LED Mode Levels
#define LED_FULL_ON 255
#define LED_FULL_OFF 0
#define DOOR_LED_LEVEL_IDLE 255
#define DOOR_LED_LEVEL_RUN 100
#define DOOR_LED_THROB_MIN 60
#define DOOR_LED_RISE_TIME 3 // the time it takes to fade on
#define DOOR_SLEEP_THROB_RATE 4 // define how the sleep throb looks
#define DOOR_SLEEP_THROB_MIN 5
#define SPINDLE_LED_LEVEL_IDLE 0
#define SPINDLE_LED_LEVEL_RUN 255
#define SPINDLE_LED_THROB_MIN 60
#define SPINDLE_LED_RISE_TIME 3 // the time it takes to fade on
#define SPINDLE_LED_THROB_RATE 2
#define BUTTON_LED_LEVEL_ON 255
#define BUTTON_LED_LEVEL_OFF 0
#define BUTTON_LED_THROB_MIN 60
#define BUTTON_LED_THROB_RATE 1 // 1/2 second
#define BUTTON_LED_RISE_TIME 3 // the time it takes to fade on
#define CARVIN_TIMING_CTC 120 // timer interrupt compare value...set this for a roughly 512 hz interrupt, so we can fade 256 levels in 1/2 second
#define CONTROL_DEBOUNCE_COUNT 8 // this is count down by timer5
extern int control_button_counter; // Used to debounce the control button.
int use_sleep_feature;
int hardware_rev;
struct pwm_analog{
unsigned char target; // what is the desired brightness
unsigned char current_level; // how bright is is now
unsigned char duration; // time in 1/2 seconds to get there (3 = 1.5 seconds)...0 = on right away
unsigned char dur_counter; // where are we in the duration delay
unsigned char throb; // 1 = light will throb...fade on...fade off
unsigned char throb_min; // what is the minimum brightness of the throb. It can look harsh if it goes off or nearly off
};
extern void carvin_init();
// functions to work with the LEDs
void init_pwm(struct pwm_analog * led);
extern void set_pwm(struct pwm_analog * led, unsigned char target_level, unsigned char duration);
int pwm_level_change(struct pwm_analog * led); // checks to see if a level change is needed
void set_button_led();
extern void throb_pwm(struct pwm_analog * pwm, uint8_t min_throb, uint8_t duration);
extern uint8_t get_hardware_rev(); // return the hardware rev number
extern void reset_cpu(); // software full reset of the CPU
extern void print_switch_states();
// the LEDs
struct pwm_analog button_led;
struct pwm_analog door_led;
struct pwm_analog spindle_led;
struct pwm_analog spindle_motor;
#endif