Renamed zones into banks to align to M17 codeplug naming convention.
This commit is contained in:
parent
6caf531b85
commit
c3cfaba4b2
|
|
@ -123,14 +123,14 @@ __attribute__((packed)) channel_t;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data structure containing all the information of a zone.
|
* Data structure containing all the information of a bank.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char name[16]; /**< Zone name */
|
char name[16]; /**< Bank name */
|
||||||
uint16_t member[64]; /**< Channel indexes */
|
uint16_t member[64]; /**< Channel indexes */
|
||||||
}
|
}
|
||||||
__attribute__((packed)) zone_t;
|
__attribute__((packed)) bank_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data structure containing all the information of a contact.
|
* Data structure containing all the information of a contact.
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,8 @@ typedef struct
|
||||||
uint16_t channel_index;
|
uint16_t channel_index;
|
||||||
channel_t channel;
|
channel_t channel;
|
||||||
channel_t vfo_channel;
|
channel_t vfo_channel;
|
||||||
bool zone_enabled;
|
bool bank_enabled;
|
||||||
zone_t zone;
|
bank_t bank;
|
||||||
uint8_t rtxStatus;
|
uint8_t rtxStatus;
|
||||||
bool rtxShutdown;
|
bool rtxShutdown;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ enum uiScreen
|
||||||
MODE_VFO,
|
MODE_VFO,
|
||||||
MODE_MEM,
|
MODE_MEM,
|
||||||
MENU_TOP,
|
MENU_TOP,
|
||||||
MENU_ZONE,
|
MENU_BANK,
|
||||||
MENU_CHANNEL,
|
MENU_CHANNEL,
|
||||||
MENU_CONTACTS,
|
MENU_CONTACTS,
|
||||||
MENU_GPS,
|
MENU_GPS,
|
||||||
|
|
@ -72,7 +72,7 @@ enum SetRxTx
|
||||||
// menu elements even if some elements may be missing (GPS)
|
// menu elements even if some elements may be missing (GPS)
|
||||||
enum menuItems
|
enum menuItems
|
||||||
{
|
{
|
||||||
M_ZONE = 0,
|
M_BANK = 0,
|
||||||
M_CHANNEL,
|
M_CHANNEL,
|
||||||
M_CONTACTS,
|
M_CONTACTS,
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
|
|
|
||||||
|
|
@ -73,19 +73,19 @@ int nvm_readVFOChannelData(channel_t *channel);
|
||||||
int nvm_readChannelData(channel_t *channel, uint16_t pos);
|
int nvm_readChannelData(channel_t *channel, uint16_t pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read one zone from table stored in nonvolatile memory.
|
* Read one bank from table stored in nonvolatile memory.
|
||||||
*
|
*
|
||||||
* @param zone: pointer to the zone_t data structure to be populated.
|
* @param bank: pointer to the bank_t data structure to be populated.
|
||||||
* @param pos: position, inside the zone table, from which read data.
|
* @param pos: position, inside the bank table, from which read data.
|
||||||
* @return 0 on success, -1 on failure
|
* @return 0 on success, -1 on failure
|
||||||
*/
|
*/
|
||||||
int nvm_readZoneData(zone_t *zone, uint16_t pos);
|
int nvm_readBankData(bank_t *bank, uint16_t pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read one contact from table stored in nonvolatile memory.
|
* Read one contact from table stored in nonvolatile memory.
|
||||||
*
|
*
|
||||||
* @param contact: pointer to the contact_t data structure to be populated.
|
* @param contact: pointer to the contact_t data structure to be populated.
|
||||||
* @param pos: position, inside the zone table, from which read data.
|
* @param pos: position, inside the bank table, from which read data.
|
||||||
* @return 0 on success, -1 on failure
|
* @return 0 on success, -1 on failure
|
||||||
*/
|
*/
|
||||||
int nvm_readContactData(contact_t *contact, uint16_t pos);
|
int nvm_readContactData(contact_t *contact, uint16_t pos);
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ void state_init()
|
||||||
state.rssi = rtx_getRssi();
|
state.rssi = rtx_getRssi();
|
||||||
|
|
||||||
state.channel_index = 1; // Set default channel index (it is 1-based)
|
state.channel_index = 1; // Set default channel index (it is 1-based)
|
||||||
state.zone_enabled = false;
|
state.bank_enabled = false;
|
||||||
state.rtxStatus = RTX_OFF;
|
state.rtxStatus = RTX_OFF;
|
||||||
state.rtxShutdown = false;
|
state.rtxShutdown = false;
|
||||||
state.emergency = false;
|
state.emergency = false;
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ extern void _ui_drawModeVFO();
|
||||||
extern void _ui_drawModeMEM();
|
extern void _ui_drawModeMEM();
|
||||||
/* UI menu functions, their implementation is in "ui_menu.c" */
|
/* UI menu functions, their implementation is in "ui_menu.c" */
|
||||||
extern void _ui_drawMenuTop(ui_state_t* ui_state);
|
extern void _ui_drawMenuTop(ui_state_t* ui_state);
|
||||||
extern void _ui_drawMenuZone(ui_state_t* ui_state);
|
extern void _ui_drawMenuBank(ui_state_t* ui_state);
|
||||||
extern void _ui_drawMenuChannel(ui_state_t* ui_state);
|
extern void _ui_drawMenuChannel(ui_state_t* ui_state);
|
||||||
extern void _ui_drawMenuContacts(ui_state_t* ui_state);
|
extern void _ui_drawMenuContacts(ui_state_t* ui_state);
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
|
|
@ -114,7 +114,7 @@ extern bool _ui_drawMacroMenu();
|
||||||
|
|
||||||
const char *menu_items[] =
|
const char *menu_items[] =
|
||||||
{
|
{
|
||||||
"Zone",
|
"Banks",
|
||||||
"Channels",
|
"Channels",
|
||||||
"Contacts",
|
"Contacts",
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
|
|
@ -537,26 +537,26 @@ bool _ui_drawDarkOverlay() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _ui_fsm_loadChannel(uint16_t zone_index, bool *sync_rtx) {
|
int _ui_fsm_loadChannel(uint16_t bank_index, bool *sync_rtx) {
|
||||||
uint16_t channel_index = zone_index;
|
uint16_t channel_index = bank_index;
|
||||||
channel_t channel;
|
channel_t channel;
|
||||||
// If a zone is active, get index from current zone
|
// If a bank is active, get index from current bank
|
||||||
if(state.zone_enabled)
|
if(state.bank_enabled)
|
||||||
{
|
{
|
||||||
// Calculate zone size
|
// Calculate bank size
|
||||||
const uint8_t zone_size = sizeof(state.zone.member)/sizeof(state.zone.member[0]);
|
const uint8_t bank_size = sizeof(state.bank.member)/sizeof(state.bank.member[0]);
|
||||||
if((zone_index <= 0) || (zone_index > zone_size))
|
if((bank_index <= 0) || (bank_index > bank_size))
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
// Channel index is 1-based while zone array access is 0-based
|
// Channel index is 1-based while bank array access is 0-based
|
||||||
channel_index = state.zone.member[zone_index - 1];
|
channel_index = state.bank.member[bank_index - 1];
|
||||||
}
|
}
|
||||||
int result = nvm_readChannelData(&channel, channel_index);
|
int result = nvm_readChannelData(&channel, channel_index);
|
||||||
// Read successful and channel is valid
|
// Read successful and channel is valid
|
||||||
if(result != -1 && _ui_channel_valid(&channel))
|
if(result != -1 && _ui_channel_valid(&channel))
|
||||||
{
|
{
|
||||||
// Set new channel index
|
// Set new channel index
|
||||||
state.channel_index = zone_index;
|
state.channel_index = bank_index;
|
||||||
// Copy channel read to state
|
// Copy channel read to state
|
||||||
state.channel = channel;
|
state.channel = channel;
|
||||||
*sync_rtx = true;
|
*sync_rtx = true;
|
||||||
|
|
@ -1262,8 +1262,8 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
{
|
{
|
||||||
switch(ui_state.menu_selected)
|
switch(ui_state.menu_selected)
|
||||||
{
|
{
|
||||||
case M_ZONE:
|
case M_BANK:
|
||||||
state.ui_screen = MENU_ZONE;
|
state.ui_screen = MENU_BANK;
|
||||||
break;
|
break;
|
||||||
case M_CHANNEL:
|
case M_CHANNEL:
|
||||||
state.ui_screen = MENU_CHANNEL;
|
state.ui_screen = MENU_CHANNEL;
|
||||||
|
|
@ -1296,7 +1296,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
_ui_menuBack(ui_state.last_main_state);
|
_ui_menuBack(ui_state.last_main_state);
|
||||||
break;
|
break;
|
||||||
// Zone menu screen
|
// Zone menu screen
|
||||||
case MENU_ZONE:
|
case MENU_BANK:
|
||||||
// Channel menu screen
|
// Channel menu screen
|
||||||
case MENU_CHANNEL:
|
case MENU_CHANNEL:
|
||||||
// Contacts menu screen
|
// Contacts menu screen
|
||||||
|
|
@ -1306,12 +1306,12 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
_ui_menuUp(1);
|
_ui_menuUp(1);
|
||||||
else if(msg.keys & KEY_DOWN || msg.keys & KNOB_RIGHT)
|
else if(msg.keys & KEY_DOWN || msg.keys & KNOB_RIGHT)
|
||||||
{
|
{
|
||||||
if(state.ui_screen == MENU_ZONE)
|
if(state.ui_screen == MENU_BANK)
|
||||||
{
|
{
|
||||||
zone_t zone;
|
bank_t bank;
|
||||||
// menu_selected is 0-based while channels are 1-based
|
// menu_selected is 0-based while channels are 1-based
|
||||||
// menu_selected == 0 corresponds to "All Channels" zone
|
// menu_selected == 0 corresponds to "All Channels" bank
|
||||||
if(nvm_readZoneData(&zone, ui_state.menu_selected + 1) != -1)
|
if(nvm_readBankData(&bank, ui_state.menu_selected + 1) != -1)
|
||||||
ui_state.menu_selected += 1;
|
ui_state.menu_selected += 1;
|
||||||
}
|
}
|
||||||
else if(state.ui_screen == MENU_CHANNEL)
|
else if(state.ui_screen == MENU_CHANNEL)
|
||||||
|
|
@ -1331,25 +1331,25 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
}
|
}
|
||||||
else if(msg.keys & KEY_ENTER)
|
else if(msg.keys & KEY_ENTER)
|
||||||
{
|
{
|
||||||
if(state.ui_screen == MENU_ZONE)
|
if(state.ui_screen == MENU_BANK)
|
||||||
{
|
{
|
||||||
zone_t newzone;
|
bank_t newbank;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
// If "All channels" is selected, load default zone
|
// If "All channels" is selected, load default bank
|
||||||
if(ui_state.menu_selected == 0)
|
if(ui_state.menu_selected == 0)
|
||||||
state.zone_enabled = false;
|
state.bank_enabled = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state.zone_enabled = true;
|
state.bank_enabled = true;
|
||||||
result = nvm_readZoneData(&newzone, ui_state.menu_selected);
|
result = nvm_readBankData(&newbank, ui_state.menu_selected);
|
||||||
}
|
}
|
||||||
if(result != -1)
|
if(result != -1)
|
||||||
{
|
{
|
||||||
state.zone = newzone;
|
state.bank = newbank;
|
||||||
// If we were in VFO mode, save VFO channel
|
// If we were in VFO mode, save VFO channel
|
||||||
if(ui_state.last_main_state == MAIN_VFO)
|
if(ui_state.last_main_state == MAIN_VFO)
|
||||||
state.vfo_channel = state.channel;
|
state.vfo_channel = state.channel;
|
||||||
// Load zone first channel
|
// Load bank first channel
|
||||||
_ui_fsm_loadChannel(1, sync_rtx);
|
_ui_fsm_loadChannel(1, sync_rtx);
|
||||||
// Switch to MEM screen
|
// Switch to MEM screen
|
||||||
state.ui_screen = MAIN_MEM;
|
state.ui_screen = MAIN_MEM;
|
||||||
|
|
@ -1705,8 +1705,8 @@ void ui_updateGUI()
|
||||||
_ui_drawMenuTop(&ui_state);
|
_ui_drawMenuTop(&ui_state);
|
||||||
break;
|
break;
|
||||||
// Zone menu screen
|
// Zone menu screen
|
||||||
case MENU_ZONE:
|
case MENU_BANK:
|
||||||
_ui_drawMenuZone(&ui_state);
|
_ui_drawMenuBank(&ui_state);
|
||||||
break;
|
break;
|
||||||
// Channel menu screen
|
// Channel menu screen
|
||||||
case MENU_CHANNEL:
|
case MENU_CHANNEL:
|
||||||
|
|
|
||||||
|
|
@ -71,15 +71,15 @@ void _ui_drawMainTop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _ui_drawZoneChannel()
|
void _ui_drawBankChannel()
|
||||||
{
|
{
|
||||||
// Print Zone name
|
// Print Bank name
|
||||||
if(!last_state.zone_enabled)
|
if(!last_state.bank_enabled)
|
||||||
gfx_print(layout.line1_pos, layout.line1_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line1_pos, layout.line1_font, TEXT_ALIGN_LEFT,
|
||||||
color_white, "zone: All channels");
|
color_white, "bank: All channels");
|
||||||
else
|
else
|
||||||
gfx_print(layout.line1_pos, layout.line1_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line1_pos, layout.line1_font, TEXT_ALIGN_LEFT,
|
||||||
color_white, "zone: %.13s", last_state.zone.name);
|
color_white, "bank: %.13s", last_state.bank.name);
|
||||||
// Print Channel name
|
// Print Channel name
|
||||||
gfx_print(layout.line2_pos, layout.line2_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line2_pos, layout.line2_font, TEXT_ALIGN_LEFT,
|
||||||
color_white, " %03d: %.12s",
|
color_white, " %03d: %.12s",
|
||||||
|
|
@ -158,9 +158,9 @@ void _ui_drawMainBottom()
|
||||||
// Squelch bar
|
// Squelch bar
|
||||||
float rssi = last_state.rssi;
|
float rssi = last_state.rssi;
|
||||||
float squelch = last_state.settings.sqlLevel / 16.0f;
|
float squelch = last_state.settings.sqlLevel / 16.0f;
|
||||||
uint16_t meter_width = SCREEN_WIDTH - 2 * layout.horizontal_pad;
|
uint16_t meter_width = SCREEN_WIDTH - 2 * layout.horizontal_pad;
|
||||||
uint16_t meter_height = layout.bottom_h;
|
uint16_t meter_height = layout.bottom_h;
|
||||||
point_t meter_pos = { layout.horizontal_pad,
|
point_t meter_pos = { layout.horizontal_pad,
|
||||||
SCREEN_HEIGHT - meter_height - layout.bottom_pad};
|
SCREEN_HEIGHT - meter_height - layout.bottom_pad};
|
||||||
uint8_t mic_level = platform_getMicLevel();
|
uint8_t mic_level = platform_getMicLevel();
|
||||||
switch(last_state.channel.mode)
|
switch(last_state.channel.mode)
|
||||||
|
|
@ -210,7 +210,7 @@ void _ui_drawMainMEM()
|
||||||
{
|
{
|
||||||
gfx_clearScreen();
|
gfx_clearScreen();
|
||||||
_ui_drawMainTop();
|
_ui_drawMainTop();
|
||||||
_ui_drawZoneChannel();
|
_ui_drawBankChannel();
|
||||||
_ui_drawFrequency();
|
_ui_drawFrequency();
|
||||||
_ui_drawMainBottom();
|
_ui_drawMainBottom();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -256,20 +256,20 @@ int _ui_getInfoValueName(char *buf, uint8_t max_len, uint8_t index)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _ui_getZoneName(char *buf, uint8_t max_len, uint8_t index)
|
int _ui_getBankName(char *buf, uint8_t max_len, uint8_t index)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
// First zone "All channels" is not read from flash
|
// First bank "All channels" is not read from flash
|
||||||
if(index == 0)
|
if(index == 0)
|
||||||
{
|
{
|
||||||
snprintf(buf, max_len, "All channels");
|
snprintf(buf, max_len, "All channels");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
zone_t zone;
|
bank_t bank;
|
||||||
result = nvm_readZoneData(&zone, index);
|
result = nvm_readBankData(&bank, index);
|
||||||
if(result != -1)
|
if(result != -1)
|
||||||
snprintf(buf, max_len, "%s", zone.name);
|
snprintf(buf, max_len, "%s", bank.name);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -302,14 +302,14 @@ void _ui_drawMenuTop(ui_state_t* ui_state)
|
||||||
_ui_drawMenuList(ui_state->menu_selected, _ui_getMenuTopEntryName);
|
_ui_drawMenuList(ui_state->menu_selected, _ui_getMenuTopEntryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _ui_drawMenuZone(ui_state_t* ui_state)
|
void _ui_drawMenuBank(ui_state_t* ui_state)
|
||||||
{
|
{
|
||||||
gfx_clearScreen();
|
gfx_clearScreen();
|
||||||
// Print "Zone" on top bar
|
// Print "Bank" on top bar
|
||||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
color_white, "Zone");
|
color_white, "Bank");
|
||||||
// Print zone entries
|
// Print bank entries
|
||||||
_ui_drawMenuList(ui_state->menu_selected, _ui_getZoneName);
|
_ui_drawMenuList(ui_state->menu_selected, _ui_getBankName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _ui_drawMenuChannel(ui_state_t* ui_state)
|
void _ui_drawMenuChannel(ui_state_t* ui_state)
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,8 @@ typedef struct {
|
||||||
__attribute__((packed)) gdxZone_t;
|
__attribute__((packed)) gdxZone_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t bitmap[32]; // bit set when zone valid
|
uint8_t bitmap[32]; // bit set when bank valid
|
||||||
gdxZone_t zone[250];
|
gdxZone_t bank[250];
|
||||||
}
|
}
|
||||||
__attribute__((packed)) gdxZoneBank_t;
|
__attribute__((packed)) gdxZoneBank_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
|
* Copyright (C) 2020 - 2022 by Federico Amedeo Izzo IU2NUO, *
|
||||||
* Niccolò Izzo IU2KIN *
|
* Niccolò Izzo IU2KIN *
|
||||||
* Frederik Saraci IU2NRO *
|
* Frederik Saraci IU2NRO *
|
||||||
* Silvano Seva IU2KWO *
|
* Silvano Seva IU2KWO *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
|
@ -259,7 +259,7 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
|
||||||
|
|
||||||
// Channels are organized in 128-channel banks
|
// Channels are organized in 128-channel banks
|
||||||
uint8_t bank_num = (pos - 1) / 128;
|
uint8_t bank_num = (pos - 1) / 128;
|
||||||
// Note: pos is 1-based because an empty slot in a zone contains index 0
|
// Note: pos is 1-based because an empty slot in a bank contains index 0
|
||||||
uint8_t bank_channel = (pos - 1) % 128;
|
uint8_t bank_channel = (pos - 1) % 128;
|
||||||
|
|
||||||
// ### Read channel bank bitmap ###
|
// ### Read channel bank bitmap ###
|
||||||
|
|
@ -372,36 +372,36 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
int nvm_readBankData(bank_t* bank, uint16_t pos)
|
||||||
{
|
{
|
||||||
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
||||||
|
|
||||||
// zone number is 1-based to be consistent with channels
|
// bank number is 1-based to be consistent with channels
|
||||||
// Convert to 0-based index to fetch data from flash
|
// Convert to 0-based index to fetch data from flash
|
||||||
uint16_t index = pos - 1;
|
uint16_t index = pos - 1;
|
||||||
// ### Read zone bank bitmap ###
|
// ### Read bank bank bitmap ###
|
||||||
uint8_t bitmap[32];
|
uint8_t bitmap[32];
|
||||||
AT24Cx_readData(zoneBaseAddr, ((uint8_t *) &bitmap), sizeof(bitmap));
|
AT24Cx_readData(zoneBaseAddr, ((uint8_t *) &bitmap), sizeof(bitmap));
|
||||||
|
|
||||||
uint8_t bitmap_byte = index / 8;
|
uint8_t bitmap_byte = index / 8;
|
||||||
uint8_t bitmap_bit = index % 8;
|
uint8_t bitmap_bit = index % 8;
|
||||||
// The zone is marked not valid in the bitmap
|
// The bank is marked not valid in the bitmap
|
||||||
if(!(bitmap[bitmap_byte] & (1 << bitmap_bit))) return -1;
|
if(!(bitmap[bitmap_byte] & (1 << bitmap_bit))) return -1;
|
||||||
|
|
||||||
gdxZone_t zoneData;
|
gdxZone_t zoneData;
|
||||||
uint32_t zoneAddr = zoneBaseAddr + sizeof(bitmap) + index * sizeof(gdxZone_t);
|
uint32_t zoneAddr = zoneBaseAddr + sizeof(bitmap) + index * sizeof(gdxZone_t);
|
||||||
AT24Cx_readData(zoneAddr, ((uint8_t *) &zoneData), sizeof(gdxZone_t));
|
AT24Cx_readData(zoneAddr, ((uint8_t *) &zoneData), sizeof(gdxZone_t));
|
||||||
|
|
||||||
// Check if zone is empty
|
// Check if bank is empty
|
||||||
if(wcslen((wchar_t *) zoneData.name) == 0) return -1;
|
if(wcslen((wchar_t *) zoneData.name) == 0) return -1;
|
||||||
|
|
||||||
memcpy(zone->name, zoneData.name, sizeof(zoneData.name));
|
memcpy(bank->name, zoneData.name, sizeof(zoneData.name));
|
||||||
// Terminate string with 0x00 instead of 0xFF
|
// Terminate string with 0x00 instead of 0xFF
|
||||||
_addStringTerminator(zone->name, sizeof(zoneData.name));
|
_addStringTerminator(bank->name, sizeof(zoneData.name));
|
||||||
// Copy zone channel indexes
|
// Copy bank channel indexes
|
||||||
for(uint16_t i = 0; i < 16; i++)
|
for(uint16_t i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
zone->member[i] = zoneData.member[i];
|
bank->member[i] = zoneData.member[i];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
|
* Copyright (C) 2020 - 2022 by Federico Amedeo Izzo IU2NUO, *
|
||||||
* Niccolò Izzo IU2KIN *
|
* Niccolò Izzo IU2KIN *
|
||||||
* Frederik Saraci IU2NRO *
|
* Frederik Saraci IU2NRO *
|
||||||
* Silvano Seva IU2KWO *
|
* Silvano Seva IU2KWO *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
|
@ -252,7 +252,7 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
int nvm_readBankData(bank_t* bank, uint16_t pos)
|
||||||
{
|
{
|
||||||
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
||||||
|
|
||||||
|
|
@ -274,12 +274,12 @@ int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
||||||
*/
|
*/
|
||||||
for(uint16_t i = 0; i < 16; i++)
|
for(uint16_t i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
zone->name[i] = ((char) (zoneData.name[i] & 0x00FF));
|
bank->name[i] = ((char) (zoneData.name[i] & 0x00FF));
|
||||||
}
|
}
|
||||||
// Copy zone channel indexes
|
// Copy zone channel indexes
|
||||||
for(uint16_t i = 0; i < 16; i++)
|
for(uint16_t i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
zone->member[i] = zoneData.member[i];
|
bank->member[i] = zoneData.member[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2021 by Federico Amedeo Izzo IU2NUO, *
|
* Copyright (C) 2020 - 2022 by Federico Amedeo Izzo IU2NUO, *
|
||||||
* Niccolò Izzo IU2KIN *
|
* Niccolò Izzo IU2KIN *
|
||||||
* Frederik Saraci IU2NRO *
|
* Frederik Saraci IU2NRO *
|
||||||
* Silvano Seva IU2KWO *
|
* Silvano Seva IU2KWO *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
|
@ -186,7 +186,7 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
|
||||||
return _nvm_readChannelAtAddress(channel, readAddr);
|
return _nvm_readChannelAtAddress(channel, readAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
int nvm_readBankData(bank_t* bank, uint16_t pos)
|
||||||
{
|
{
|
||||||
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
||||||
|
|
||||||
|
|
@ -211,17 +211,17 @@ int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
||||||
*/
|
*/
|
||||||
for(uint16_t i = 0; i < 16; i++)
|
for(uint16_t i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
zone->name[i] = ((char) (zoneData.name[i] & 0x00FF));
|
bank->name[i] = ((char) (zoneData.name[i] & 0x00FF));
|
||||||
}
|
}
|
||||||
// Copy zone channel indexes
|
// Copy zone channel indexes
|
||||||
for(uint16_t i = 0; i < 16; i++)
|
for(uint16_t i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
zone->member[i] = zoneData.member_a[i];
|
bank->member[i] = zoneData.member_a[i];
|
||||||
}
|
}
|
||||||
// Copy zone extension channel indexes
|
// Copy zone extension channel indexes
|
||||||
for(uint16_t i = 0; i < 48; i++)
|
for(uint16_t i = 0; i < 48; i++)
|
||||||
{
|
{
|
||||||
zone->member[16 + i] = zoneExtData.ext_a[i];
|
bank->member[16 + i] = zoneExtData.ext_a[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
|
* Copyright (C) 2020 - 2022 by Federico Amedeo Izzo IU2NUO, *
|
||||||
* Niccolò Izzo IU2KIN *
|
* Niccolò Izzo IU2KIN *
|
||||||
* Frederik Saraci IU2NRO *
|
* Frederik Saraci IU2NRO *
|
||||||
* Silvano Seva IU2KWO *
|
* Silvano Seva IU2KWO *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
|
@ -286,7 +286,7 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
|
||||||
return _nvm_readChannelAtAddress(channel, readAddr);
|
return _nvm_readChannelAtAddress(channel, readAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
int nvm_readBankData(bank_t* bank, uint16_t pos)
|
||||||
{
|
{
|
||||||
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
||||||
|
|
||||||
|
|
@ -311,17 +311,17 @@ int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
||||||
*/
|
*/
|
||||||
for(uint16_t i = 0; i < 16; i++)
|
for(uint16_t i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
zone->name[i] = ((char) (zoneData.name[i] & 0x00FF));
|
bank->name[i] = ((char) (zoneData.name[i] & 0x00FF));
|
||||||
}
|
}
|
||||||
// Copy zone channel indexes
|
// Copy zone channel indexes
|
||||||
for(uint16_t i = 0; i < 16; i++)
|
for(uint16_t i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
zone->member[i] = zoneData.member_a[i];
|
bank->member[i] = zoneData.member_a[i];
|
||||||
}
|
}
|
||||||
// Copy zone extension channel indexes
|
// Copy zone extension channel indexes
|
||||||
for(uint16_t i = 0; i < 48; i++)
|
for(uint16_t i = 0; i < 48; i++)
|
||||||
{
|
{
|
||||||
zone->member[16 + i] = zoneExtData.ext_a[i];
|
bank->member[16 + i] = zoneExtData.ext_a[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,9 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
int nvm_readBankData(bank_t* bank, uint16_t pos)
|
||||||
{
|
{
|
||||||
(void) zone;
|
(void) bank;
|
||||||
(void) pos;
|
(void) pos;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
|
* Copyright (C) 2020 - 2022 by Federico Amedeo Izzo IU2NUO, *
|
||||||
* Niccolò Izzo IU2KIN *
|
* Niccolò Izzo IU2KIN *
|
||||||
* Frederik Saraci IU2NRO *
|
* Frederik Saraci IU2NRO *
|
||||||
* Silvano Seva IU2KWO *
|
* Silvano Seva IU2KWO *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
|
@ -247,17 +247,17 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
int nvm_readBankData(bank_t* bank, uint16_t pos)
|
||||||
{
|
{
|
||||||
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
||||||
|
|
||||||
/* Generate dummy zone name */
|
/* Generate dummy bank name */
|
||||||
snprintf(zone->name, 16, "Zone %d", pos);
|
snprintf(bank->name, 16, "Zone %d", pos);
|
||||||
memset(zone->member, 0, sizeof(zone->member));
|
memset(bank->member, 0, sizeof(bank->member));
|
||||||
// Add fake zone member indexes
|
// Add fake bank member indexes
|
||||||
zone->member[0] = pos;
|
bank->member[0] = pos;
|
||||||
zone->member[1] = pos+1;
|
bank->member[1] = pos+1;
|
||||||
zone->member[2] = pos+2;
|
bank->member[2] = pos+2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,17 +51,17 @@ int main()
|
||||||
printf("Zones:\r\n");
|
printf("Zones:\r\n");
|
||||||
for(int pos=0,result=0; result != -1; pos++)
|
for(int pos=0,result=0; result != -1; pos++)
|
||||||
{
|
{
|
||||||
zone_t zone;
|
zone_t bank;
|
||||||
result = nvm_readZoneData(&zone, pos);
|
result = nvm_readZoneData(&bank, pos);
|
||||||
if(result != -1)
|
if(result != -1)
|
||||||
{
|
{
|
||||||
printf("Zone n.%d:\r\n", pos+1);
|
printf("Zone n.%d:\r\n", pos+1);
|
||||||
printf(" %s\r\n", zone.name);
|
printf(" %s\r\n", bank.name);
|
||||||
for(int x=0; x < 64; x++)
|
for(int x=0; x < 64; x++)
|
||||||
{
|
{
|
||||||
if(zone.member[x] != 0)
|
if(bank.member[x] != 0)
|
||||||
{
|
{
|
||||||
printf(" - Index: %d, Channel %d\r\n", x, zone.member[x]);
|
printf(" - Index: %d, Channel %d\r\n", x, bank.member[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue