mirror of
https://github.com/JorjBauer/aiie.git
synced 2024-11-29 16:49:26 +00:00
debugging
This commit is contained in:
parent
33886eef49
commit
816c38209c
@ -83,8 +83,8 @@ void TeensySpeaker::maintainSpeaker()
|
||||
togmutex.unlock();
|
||||
|
||||
// Now we can safely update the DAC based on the current toggleState
|
||||
uint16_t v = (toggleState ? 0xFFF : 0x000);
|
||||
dac.write((uint8_t) ((v >> 8) & 0xFF), (uint8_t) (v & 0xFF), true);
|
||||
// uint16_t v = (toggleState ? 0xFFF : 0x000);
|
||||
// dac.write((uint8_t) ((v >> 8) & 0xFF), (uint8_t) (v & 0xFF), true);
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "physicalspeaker.h"
|
||||
#include <MCP492X.h>
|
||||
|
||||
#define SAMPLERATE 4000
|
||||
#define SAMPLERATE 8000
|
||||
|
||||
class TeensySpeaker : public PhysicalSpeaker {
|
||||
public:
|
||||
|
@ -164,6 +164,7 @@ void setup()
|
||||
Serial.flush();
|
||||
|
||||
threads.setMicroTimer(); // use a 100uS timer instead of a 1mS timer
|
||||
// threads.setSliceMicros(5);
|
||||
threads.addThread(runDebouncer);
|
||||
}
|
||||
|
||||
@ -225,32 +226,31 @@ void biosInterrupt()
|
||||
g_keyboard->maintainKeyboard();
|
||||
}
|
||||
|
||||
uint32_t spk_nextResetMillis = 0;
|
||||
uint32_t spk_refreshCount = 0;
|
||||
uint32_t spk_microsAtStart = micros();
|
||||
uint32_t spk_microsForNext = 0;
|
||||
void runSpeaker()
|
||||
{
|
||||
static uint32_t nextResetMillis = 0;
|
||||
static uint32_t refreshCount = 0;
|
||||
static uint32_t microsAtStart = micros();
|
||||
static uint32_t microsForNext = 0;
|
||||
|
||||
if (1) {
|
||||
if (micros() >= microsForNext) {
|
||||
refreshCount++;
|
||||
microsForNext = microsAtStart + ((1000000*refreshCount)/SAMPLERATE);
|
||||
// ((TeensySpeaker *)g_speaker)->maintainSpeaker();
|
||||
if (micros() >= spk_microsForNext) {
|
||||
spk_refreshCount++;
|
||||
spk_microsForNext = spk_microsAtStart + ((1000000*spk_refreshCount)/SAMPLERATE);
|
||||
((TeensySpeaker *)g_speaker)->maintainSpeaker();
|
||||
}
|
||||
|
||||
if (millis() >= nextResetMillis) {
|
||||
nextResetMillis = millis() + 1000;
|
||||
if (millis() >= spk_nextResetMillis) {
|
||||
spk_nextResetMillis = millis() + 1000;
|
||||
#ifdef DEBUG_TIMING
|
||||
static char buf[25];
|
||||
float pct = (100.0 * (float)refreshCount) / (float)SAMPLERATE;
|
||||
sprintf(buf, "Speaker running at %f%% [%lu]", pct, refreshCount);
|
||||
float pct = (100.0 * (float)spk_refreshCount) / (float)SAMPLERATE;
|
||||
sprintf(buf, "Speaker running at %f%% [%lu]", pct, spk_refreshCount);
|
||||
println(buf);
|
||||
#endif
|
||||
|
||||
refreshCount = 0;
|
||||
microsAtStart = micros();
|
||||
microsForNext = microsAtStart + ((1000000*refreshCount)/SAMPLERATE);
|
||||
spk_refreshCount = 0;
|
||||
spk_microsAtStart = micros();
|
||||
spk_microsForNext = spk_microsAtStart + ((1000000*spk_refreshCount)/SAMPLERATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user