now allocating `list__list_t`s as static vars instead of pointers
and a small documentation updatepartial-rewrite
parent
c24adb542c
commit
4d50761b0d
|
@ -84,10 +84,15 @@ struct {
|
|||
bool writing : 1;
|
||||
} status;
|
||||
|
||||
// TODO: i should probably pick one or the other as a standard way of declaring
|
||||
// lists; either as pointers, and then pass that, or as variables, and pass a
|
||||
// reference to them
|
||||
/** variables/to_write/description
|
||||
* A list of writes (and copies) to perform
|
||||
*/
|
||||
static list__list_t to_write;
|
||||
|
||||
/** variables/to_copy/description
|
||||
* A list of extra information for each `action == ACTION_COPY` element in
|
||||
* `to_write`
|
||||
*/
|
||||
static list__list_t to_copy;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
static volatile uint16_t _milliseconds__counter;
|
||||
static list__list_t * _milliseconds__scheduled_events = &(list__list_t){};
|
||||
static list__list_t _milliseconds__scheduled_events;
|
||||
|
||||
// since we won't be running scheduled events every "tick"
|
||||
static uint8_t _milliseconds__last_ticked;
|
||||
|
@ -54,7 +54,7 @@ uint8_t timer__schedule_milliseconds(uint16_t ticks, void(*function)(void)) {
|
|||
// - use `ticks+elapsed` to compensate for ticks that haven't been counted
|
||||
// yet, but should have (if we were ticking in real time)
|
||||
return event_list__append(
|
||||
_milliseconds__scheduled_events, ticks+elapsed, function );
|
||||
&_milliseconds__scheduled_events, ticks+elapsed, function );
|
||||
}
|
||||
|
||||
void timer___tick_milliseconds(void) {
|
||||
|
@ -65,7 +65,7 @@ void timer___tick_milliseconds(void) {
|
|||
_milliseconds__last_ticked += elapsed;
|
||||
|
||||
for (uint8_t i=0; i<elapsed; i++)
|
||||
event_list__tick(_milliseconds__scheduled_events);
|
||||
event_list__tick(&_milliseconds__scheduled_events);
|
||||
}
|
||||
|
||||
ISR(TIMER0_COMPA_vect) {
|
||||
|
|
|
@ -17,19 +17,19 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define DEFINE_TIMER(name) \
|
||||
static uint16_t _##name##__counter; \
|
||||
static list__list_t * _##name##__scheduled_events = &(list__list_t){}; \
|
||||
static uint16_t _##name##__counter; \
|
||||
static list__list_t _##name##__scheduled_events; \
|
||||
\
|
||||
uint16_t timer__get_##name(void) { \
|
||||
return _##name##__counter; \
|
||||
} \
|
||||
uint8_t timer__schedule_##name(uint16_t ticks, void(*function)(void)) { \
|
||||
return event_list__append( \
|
||||
_##name##__scheduled_events, ticks, function ); \
|
||||
&_##name##__scheduled_events, ticks, function ); \
|
||||
} \
|
||||
void timer___tick_##name(void) { \
|
||||
_##name##__counter++; \
|
||||
event_list__tick(_##name##__scheduled_events); \
|
||||
event_list__tick(&_##name##__scheduled_events); \
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue