Skip to content

Commit

Permalink
aircopy tidyup complete
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven authored and OneOfEleven committed Oct 12, 2023
1 parent 0b606e6 commit 571c722
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
13 changes: 6 additions & 7 deletions app/aircopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
#include "ui/inputbox.h"
#include "ui/ui.h"

#define AIR_COPY_MAX_BLOCK 120

static const uint16_t Obfuscation[8] = {0x6C16, 0xE614, 0x912E, 0x400D, 0x3521, 0x40D5, 0x0313, 0x80E9};

aircopy_state_t g_aircopy_state;
uint16_t g_air_copy_block_number;
uint16_t g_errors_during_air_copy;
uint16_t g_fsk_buffer[36];
const uint8_t g_air_copy_block_max = 120;
uint8_t g_air_copy_block_number;
uint8_t g_errors_during_air_copy;
aircopy_state_t g_aircopy_state;
uint16_t g_fsk_buffer[36];

void AIRCOPY_SendMessage(void)
{
Expand All @@ -49,7 +48,7 @@ void AIRCOPY_SendMessage(void)
for (i = 0; i < 34; i++)
g_fsk_buffer[i + 1] ^= Obfuscation[i % 8];

if (++g_air_copy_block_number >= AIR_COPY_MAX_BLOCK)
if (++g_air_copy_block_number >= g_air_copy_block_max)
{
g_aircopy_state = AIRCOPY_TX_COMPLETE;
g_update_display = true;
Expand Down
9 changes: 5 additions & 4 deletions app/aircopy.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ enum aircopy_state_e
};
typedef enum aircopy_state_e aircopy_state_t;

extern aircopy_state_t g_aircopy_state;
extern uint16_t g_air_copy_block_number;
extern uint16_t g_errors_during_air_copy;
extern uint16_t g_fsk_buffer[36];
extern const uint8_t g_air_copy_block_max;
extern uint8_t g_air_copy_block_number;
extern uint8_t g_errors_during_air_copy;
extern aircopy_state_t g_aircopy_state;
extern uint16_t g_fsk_buffer[36];

void AIRCOPY_SendMessage(void);
void AIRCOPY_StorePacket(void);
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
46 changes: 37 additions & 9 deletions ui/aircopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ void UI_DisplayAircopy(void)

memset(g_frame_buffer, 0, sizeof(g_frame_buffer));

// **********************************

strcpy(String, "AIR COPY");

switch (g_aircopy_state)
{
case AIRCOPY_READY: strcat(String, " READY"); break;
Expand All @@ -41,7 +44,9 @@ void UI_DisplayAircopy(void)
case AIRCOPY_TX_COMPLETE: strcat(String, " DONE"); break;
default: strcat(String, " ???"); break;
}
UI_PrintString(String, 2, 127, 0, 8);
UI_PrintString(String, 0, LCD_WIDTH - 1, 0, 8);

// **********************************

if (g_input_box_index == 0)
{
Expand All @@ -52,26 +57,49 @@ void UI_DisplayAircopy(void)
else
UI_DisplayFrequency(g_input_box, 16, 2, 1, 0);

// **********************************

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="

switch (g_aircopy_state)
{
case AIRCOPY_READY:
UI_PrintString("EXIT rx M tx", 0, 127, 5, 7);
UI_PrintString("EXIT rx M tx", 0, LCD_WIDTH - 1, 5, 7);
break;
case AIRCOPY_RX:

case AIRCOPY_RX_COMPLETE:
sprintf(String, "RCV %u E %u", g_air_copy_block_number, g_errors_during_air_copy);
UI_PrintString(String, 0, 127, 5, 8);
if (g_errors_during_air_copy == 0)
{
UI_PrintString("RX COMPLETE", 0, LCD_WIDTH - 1, 5, 8);
break;
}

case AIRCOPY_RX:
sprintf(String, "RX %u.%u", g_air_copy_block_number, g_air_copy_block_max);
if (g_errors_during_air_copy > 0)
sprintf(String + strlen(String), " E %u", g_errors_during_air_copy);
UI_PrintString(String, 0, LCD_WIDTH - 1, 5, 7);
break;
case AIRCOPY_TX:

case AIRCOPY_TX_COMPLETE:
sprintf(String, "SND %u", g_air_copy_block_number);
UI_PrintString(String, 0, 127, 5, 8);
UI_PrintString("TX COMPLETE", 0, LCD_WIDTH - 1, 5, 8);
break;

case AIRCOPY_TX:
sprintf(String, "TX %u.%u", g_air_copy_block_number, g_air_copy_block_max);
UI_PrintString(String, 0, LCD_WIDTH - 1, 5, 7);
break;

default:
strcpy(String, " ???");
UI_PrintString(String, 0, 127, 5, 8);
UI_PrintString(String, 0, LCD_WIDTH - 1, 5, 7);
break;
}

#pragma GCC diagnostic pop

// **********************************

ST7565_BlitFullScreen();
}

0 comments on commit 571c722

Please sign in to comment.