Compare commits

..

No commits in common. "vu-meter" and "master" have entirely different histories.

2 changed files with 1 additions and 96 deletions

@ -1 +1 @@
Subproject commit ed32a6d2fd0c2544ef753aa9e827660e56ff7d59
Subproject commit 7828be22aa5a97c31f8d8286b50336f9193224a1

View File

@ -25,8 +25,6 @@
#include "uart.h"
#include "hcs12ss59t/hcs12ss59t.h"
void vu_meter();
enum {
SEND_ENCAPSULATED_COMMAND = 0,
GET_ENCAPSULATED_RESPONSE,
@ -294,7 +292,6 @@ void waitboot()
int main(void)
{
waitboot();
vu_meter(); // For debugging only
wdt_enable(WDTO_1S);
odDebugInit();
hardwareInit();
@ -345,95 +342,3 @@ int main(void)
return 0;
}
#define ADC_NOISE 15 // ADC RAW value
#define BAR_SPEED 22 // In application cycles
#define PK_SPEED 40 // In application cycles
#define PK_DELAY 36 // In PKBAR cycles
void vu_meter()
{
uint16_t vu_new;
uint8_t vu[2] = {0, 0};
uint8_t pk[2] = {0, 0};
uint8_t pk_del[2] = {0, 0};
uint16_t adc_val[2];
int cnt = 0;
uint16_t adc_max = 175;
int i;
cli();
/* Config ADC */
ADCSRA = (1 << ADEN) | (1 << ADPS1);
hcs12ss59t_init();
DDRD |= (1 << PD0);
FILAMENT_EN;
hcs12ss59t_set_brightness(8);
hcs12ss59t_set_text(" HCS12SS59T ");
hcs12ss59t_en_progress();
/* main event loop */
for(;;){
if (!(PIND & (1 << PD7))) {
cli();
hcs12ss59t_set_text("-BOOTLOADER-");
FILAMENT_DIS;
wdt_enable(WDTO_15MS);
while (1); // WD Timeout -> CPU reset
}
/* Acquire data */
ADMUX = (4) | (1 << REFS0) | (1 << REFS1) | (1 << REFS1);
ADCSRA |= (1 << ADSC);
while (!(ADCSRA & (1 << ADIF)));
ADCSRA |= (1 << ADIF);
ADMUX = (5) | (1 << REFS0) | (1 << REFS1) | (1 << REFS1);
ADCSRA |= (1 << ADSC);
adc_val[0] = ADC;
while (!(ADCSRA & (1 << ADIF)));
ADCSRA |= (1 << ADIF);
adc_val[1] = ADC;
for (i = 0; i < 2; ++i) {
if (adc_val[i] < ADC_NOISE)
adc_val[i] = 0;
else
adc_val[i] -= ADC_NOISE;
vu_new = adc_val[i] * 60 / adc_max;
if (vu_new >= vu[i]) {
vu[i] = vu_new;
} else {
if ((cnt % BAR_SPEED) == 0) {
if (vu[i] > 0) {
vu[i] -= 1;
}
}
}
if (vu_new > pk[i]) {
pk[i] = vu_new;
pk_del[i] = PK_DELAY;
} else {
if (pk_del[i] == 0) {
if ((cnt % PK_SPEED) == 0) {
if (pk[i] > 0) {
pk[i]--;
}
}
} else {
if ((cnt % PK_SPEED) == 0) {
pk_del[i]--;
}
}
}
}
hcs12ss59t_set_progress_peak(vu[0], vu[1], pk[0], pk[1]);
if (cnt == 209)
cnt = 0;
else
cnt++;
}
}