From 43dac0a8c6ca80087b261942e4311be4e866cd2e Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Thu, 29 May 2014 10:50:33 +0200 Subject: [PATCH] borg_hw_lolshield: framerate can be adjusted in the menu, now --- profiles/LoL-Shield_Leonardo | 1 + profiles/LoL-Shield_Mega2560 | 1 + profiles/LoL-Shield_Uno-Duemilanove-Diavolino | 1 + src/borg_hw/borg_hw_lolshield.c | 14 +++++++++++--- src/borg_hw/config_lolshield.in | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/profiles/LoL-Shield_Leonardo b/profiles/LoL-Shield_Leonardo index ad9b5d3..efee960 100644 --- a/profiles/LoL-Shield_Leonardo +++ b/profiles/LoL-Shield_Leonardo @@ -21,6 +21,7 @@ BORG_HW=HW_LOLSHIELD # USER_TIMER0_FOR_WAIT=1 BRIGHTNESS=127 +FRAMERATE=80 # # Features diff --git a/profiles/LoL-Shield_Mega2560 b/profiles/LoL-Shield_Mega2560 index 0bd22c2..f5f03c2 100644 --- a/profiles/LoL-Shield_Mega2560 +++ b/profiles/LoL-Shield_Mega2560 @@ -21,6 +21,7 @@ BORG_HW=HW_LOLSHIELD # USER_TIMER0_FOR_WAIT=1 BRIGHTNESS=127 +FRAMERATE=80 # # Features diff --git a/profiles/LoL-Shield_Uno-Duemilanove-Diavolino b/profiles/LoL-Shield_Uno-Duemilanove-Diavolino index 1782dcd..ff8ae2e 100644 --- a/profiles/LoL-Shield_Uno-Duemilanove-Diavolino +++ b/profiles/LoL-Shield_Uno-Duemilanove-Diavolino @@ -21,6 +21,7 @@ BORG_HW=HW_LOLSHIELD # USER_TIMER0_FOR_WAIT=1 BRIGHTNESS=127 +FRAMERATE=80 # # Features diff --git a/src/borg_hw/borg_hw_lolshield.c b/src/borg_hw/borg_hw_lolshield.c index 001b4af..dfba28b 100644 --- a/src/borg_hw/borg_hw_lolshield.c +++ b/src/borg_hw/borg_hw_lolshield.c @@ -47,11 +47,19 @@ // buffer which holds the currently shown frame unsigned char pixmap[NUMPLANE][NUM_ROWS][LINEBYTES]; + +/* adjust frame rate at the menuconfig, this is just a fallback */ +#ifndef FRAMERATE +# define FRAMERATE 80 +#elif FRAMERATE < 1 +# error FRAMERATE must be greater than 0 +#endif + // Number of ticks of the prescaled timer per cycle per frame, based on the // CPU clock speed and the desired frame rate. -#define FRAMERATE 80UL -#define TICKS (F_CPU + 6 * (FRAMERATE << SLOWSCALERSHIFT)) / (12 * (FRAMERATE << SLOWSCALERSHIFT)) -#define CUTOFF(scaler) ((128 * 12 - 6) * FRAMERATE * scaler) +#define TICKS (F_CPU + 6ul * (FRAMERATE << SLOWSCALERSHIFT)) / \ + (12ul * (FRAMERATE << SLOWSCALERSHIFT)) +#define CUTOFF(scaler) ((128ul * 12 - 6) * FRAMERATE * scaler##ul) #if defined (__AVR_ATmega8__) || \ defined (__AVR_ATmega48__) || \ diff --git a/src/borg_hw/config_lolshield.in b/src/borg_hw/config_lolshield.in index fd99bed..e238766 100644 --- a/src/borg_hw/config_lolshield.in +++ b/src/borg_hw/config_lolshield.in @@ -3,6 +3,7 @@ comment "lolshield setup" define_int USER_TIMER0_FOR_WAIT 1 -uint "Brightness (0-127)" BRIGHTNESS 127 +uint "Brightness (0-127)" BRIGHTNESS 127 +uint "Framerate (default 80)" FRAMERATE 80 endmenu