mirror of
https://github.com/JorjBauer/aiie.git
synced 2024-12-23 05:30:07 +00:00
reimplement volume control
This commit is contained in:
parent
b955dd106f
commit
3464ba5298
@ -8,5 +8,5 @@ PhysicalKeyboard *g_keyboard = NULL;
|
|||||||
PhysicalSpeaker *g_speaker = NULL;
|
PhysicalSpeaker *g_speaker = NULL;
|
||||||
PhysicalPaddles *g_paddles = NULL;
|
PhysicalPaddles *g_paddles = NULL;
|
||||||
PhysicalPrinter *g_printer = NULL;
|
PhysicalPrinter *g_printer = NULL;
|
||||||
int16_t g_volume;
|
int16_t g_volume = 15;
|
||||||
uint8_t g_displayType = 3; // FIXME m_perfectcolor
|
uint8_t g_displayType = 3; // FIXME m_perfectcolor
|
||||||
|
@ -9,6 +9,9 @@ extern "C"
|
|||||||
|
|
||||||
#include "timeutil.h"
|
#include "timeutil.h"
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
|
||||||
// FIXME: Globals; ick.
|
// FIXME: Globals; ick.
|
||||||
static pthread_t speakerThreadID;
|
static pthread_t speakerThreadID;
|
||||||
static uint8_t curSpeakerData = 0x00;
|
static uint8_t curSpeakerData = 0x00;
|
||||||
@ -141,6 +144,8 @@ void SDLSpeaker::maintainSpeaker(uint32_t c)
|
|||||||
|
|
||||||
mixerValue >>= 3; // divide by 8
|
mixerValue >>= 3; // divide by 8
|
||||||
|
|
||||||
|
// FIXME: g_volume
|
||||||
|
|
||||||
curSpeakerData = mixerValue & 0xFF;
|
curSpeakerData = mixerValue & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,14 +125,14 @@ bool BIOS::runUntilDone()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACT_VOLPLUS:
|
case ACT_VOLPLUS:
|
||||||
g_volume += 10;
|
g_volume ++;
|
||||||
if (g_volume > 255) {
|
if (g_volume > 15) {
|
||||||
g_volume = 255;
|
g_volume = 15;
|
||||||
}
|
}
|
||||||
volumeDidChange = true;
|
volumeDidChange = true;
|
||||||
break;
|
break;
|
||||||
case ACT_VOLMINUS:
|
case ACT_VOLMINUS:
|
||||||
g_volume -= 10;
|
g_volume--;
|
||||||
if (g_volume < 0) {
|
if (g_volume < 0) {
|
||||||
g_volume = 0;
|
g_volume = 0;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ bool BIOS::isActionActive(int8_t action)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case ACT_VOLPLUS:
|
case ACT_VOLPLUS:
|
||||||
return (g_volume < 255);
|
return (g_volume < 15);
|
||||||
case ACT_VOLMINUS:
|
case ACT_VOLMINUS:
|
||||||
return (g_volume > 0);
|
return (g_volume > 0);
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ void BIOS::DrawMainMenu(int8_t selection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// draw the volume bar
|
// draw the volume bar
|
||||||
uint16_t volCutoff = 300.0 * (float)((float) g_volume / 256.0);
|
uint16_t volCutoff = 300.0 * (float)((float) g_volume / 15.0);
|
||||||
for (uint8_t y=200; y<=210; y++) {
|
for (uint8_t y=200; y<=210; y++) {
|
||||||
((TeensyDisplay *)g_display)->moveTo(10, y);
|
((TeensyDisplay *)g_display)->moveTo(10, y);
|
||||||
for (uint16_t x = 0; x< 300; x++) {
|
for (uint16_t x = 0; x< 300; x++) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "teensy-speaker.h"
|
#include "teensy-speaker.h"
|
||||||
|
|
||||||
extern int16_t g_volume;
|
#include "globals.h"
|
||||||
|
|
||||||
TeensySpeaker::TeensySpeaker(uint8_t pinNum) : PhysicalSpeaker()
|
TeensySpeaker::TeensySpeaker(uint8_t pinNum) : PhysicalSpeaker()
|
||||||
{
|
{
|
||||||
@ -37,7 +37,10 @@ void TeensySpeaker::maintainSpeaker(uint32_t c)
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
// FIXME: glad it's DAC0 and all, but... how does that relate to the pin passed in the constructor?
|
// FIXME: glad it's DAC0 and all, but... how does that relate to the pin passed in the constructor?
|
||||||
analogWriteDAC0(mixerValue); // FIXME: g_volume?
|
|
||||||
|
mixerValue >>= (16-g_volume);
|
||||||
|
|
||||||
|
analogWriteDAC0(mixerValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TeensySpeaker::beginMixing()
|
void TeensySpeaker::beginMixing()
|
||||||
|
@ -371,8 +371,8 @@ void readPrefs()
|
|||||||
if (p.magic == MAGIC) {
|
if (p.magic == MAGIC) {
|
||||||
// looks valid! Use it.
|
// looks valid! Use it.
|
||||||
Serial.println("prefs valid! Restoring volume");
|
Serial.println("prefs valid! Restoring volume");
|
||||||
if (p.volume > 4095) {
|
if (p.volume > 15) {
|
||||||
p.volume = 4095;
|
p.volume = 15;
|
||||||
}
|
}
|
||||||
if (p.volume < 0) {
|
if (p.volume < 0) {
|
||||||
p.volume = 0;
|
p.volume = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user