1
0
mirror of https://github.com/fruit-bat/pico-zxspectrum.git synced 2025-04-19 00:04:01 +03:00

Display VSYS

This commit is contained in:
Phil 2024-12-15 20:54:17 +00:00
parent ca3670b363
commit f0223951ad
4 changed files with 33 additions and 7 deletions

View File

@ -88,6 +88,9 @@ set(zxspectrum_common_libs
hardware_dma
hardware_flash # Needed for flash settings (not currently working)
hardware_sync # Needed for flash settings (not currently working)
hardware_pio
hardware_pwm
hardware_adc
Zeta
Z80
)

View File

@ -8,6 +8,7 @@
#include "BufferedInputStream.h"
#include "hardware/clocks.h"
#include "ff.h"
#include "ZxSpectrumVoltage.h"
// #define DEBUG_ZX_MENU
@ -156,13 +157,12 @@ ZxSpectrumMenu::ZxSpectrumMenu(
bool k1 = _zxSpectrum->keyboard1() && _zxSpectrum->keyboard1()->isMounted();
bool k2 = _zxSpectrum->keyboard2() && _zxSpectrum->keyboard2()->isMounted();
bool m = _zxSpectrum->mouse() && _zxSpectrum->mouse()->isMounted();
pen->printAtF(0, 0, false,"USB: Joystick%s %s%s%s, Keyboard%s %s%s%s, Mice: %s",
(jl + jr ? "s" : ""),
const float v = read_voltage_sensor();
pen->printAtF(0, 0, false,"USB: joy %s%s%s, kbd %s%s%s, mice %s VSYS: %3.1fv",
(jl ? "L" : ""), (!jl && !jr ? "0" : (!!jl & !!jr ? "&" : "")), (jr ? "R" : ""),
(k1 == k2 ? "s" : ""),
(k1 ? "1" : ""), (!k1 && !k2 ? "0" : (k1 & k2 ? "&" : "")), (k2 ? "2" : ""),
(m ? "1" : "0")
);
(m ? "1" : "0"),
v);
_devices.repaint();
});
@ -537,7 +537,7 @@ ZxSpectrumMenu::ZxSpectrumMenu(
#else
pen->printAt(0, 0, false, "ZX Spectrum 48K/128K by fruit-bat");
#endif
pen->printAtF(0, 1, false, "Build: %s", __DATE__);
pen->printAtF(0, 1, false, "VER: %s", __DATE__);
pen->printAtF(0, 2, false, "CPU: %s @%3.1fMhz", PICO_MCU, (float)clock_get_hz(clk_sys) / 1000000.0);
pen->printAt(0, SZ_FRAME_ROWS-1, false, "F1 to exit menu");
@ -652,7 +652,7 @@ void ZxSpectrumMenu::quickLoad(int slot) {
void ZxSpectrumMenu::initialise() {
loadSettings();
_pathQuickSaves.createFolders(_sdCard);
_pathTapes.createFolders(_sdCard);

22
src/ZxSpectrumVoltage.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#include "hardware/gpio.h"
#include "hardware/adc.h"
static bool voltage_sensor_ready = false;
void init_voltage_sensor() {
adc_init();
adc_gpio_init(29);
adc_select_input(3);
voltage_sensor_ready = true;
}
float read_voltage_sensor() {
if (!voltage_sensor_ready) init_voltage_sensor();
const float conversion_factor = (3.3f * 3.0f) / (1 << 12);
uint16_t result = adc_read();
const float v1 = (float)result * conversion_factor;
return v1;
}

View File

@ -174,6 +174,7 @@ set(zxspectrum_zx_lcd_common_libs
tinyusb_board
hardware_pio
hardware_pwm
hardware_adc
)
foreach(target