rename static globals g_* as gs_*, keep g_ only for exported globals

This commit is contained in:
Philippe Teuwen 2021-08-22 00:51:37 +02:00
commit 58dda7a809
6 changed files with 78 additions and 78 deletions

View file

@ -181,7 +181,7 @@ static const hintAIDList_t hintAIDList[] = {
}; };
// iso14a apdu input frame length // iso14a apdu input frame length
static uint16_t g_frame_len = 0; static uint16_t gs_frame_len = 0;
static uint16_t atsFSC[] = {16, 24, 32, 40, 48, 64, 96, 128, 256}; static uint16_t atsFSC[] = {16, 24, 32, 40, 48, 64, 96, 128, 256};
static int CmdHF14AList(const char *Cmd) { static int CmdHF14AList(const char *Cmd) {
@ -776,7 +776,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
*dataoutlen = 0; *dataoutlen = 0;
if (activateField) { if (activateField) {
// select with no disconnect and set g_frame_len // select with no disconnect and set gs_frame_len
int selres = SelectCard14443A_4(false, !silentMode, NULL); int selres = SelectCard14443A_4(false, !silentMode, NULL);
if (selres != PM3_SUCCESS) if (selres != PM3_SUCCESS)
return selres; return selres;
@ -835,7 +835,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
int SelectCard14443A_4(bool disconnect, bool verbose, iso14a_card_select_t *card) { int SelectCard14443A_4(bool disconnect, bool verbose, iso14a_card_select_t *card) {
// global vars should be prefixed with g_ // global vars should be prefixed with g_
g_frame_len = 0; gs_frame_len = 0;
if (card) { if (card) {
memset(card, 0, sizeof(iso14a_card_select_t)); memset(card, 0, sizeof(iso14a_card_select_t));
@ -884,7 +884,7 @@ int SelectCard14443A_4(bool disconnect, bool verbose, iso14a_card_select_t *card
if (resp.oldarg[0] > 1) { if (resp.oldarg[0] > 1) {
uint8_t fsci = resp.data.asBytes[1] & 0x0f; uint8_t fsci = resp.data.asBytes[1] & 0x0f;
if (fsci < ARRAYLEN(atsFSC)) { if (fsci < ARRAYLEN(atsFSC)) {
g_frame_len = atsFSC[fsci]; gs_frame_len = atsFSC[fsci];
} }
} }
} else { } else {
@ -893,7 +893,7 @@ int SelectCard14443A_4(bool disconnect, bool verbose, iso14a_card_select_t *card
if (vcard->ats_len > 1) { if (vcard->ats_len > 1) {
uint8_t fsci = vcard->ats[1] & 0x0f; uint8_t fsci = vcard->ats[1] & 0x0f;
if (fsci < ARRAYLEN(atsFSC)) { if (fsci < ARRAYLEN(atsFSC)) {
g_frame_len = atsFSC[fsci]; gs_frame_len = atsFSC[fsci];
} }
} }
@ -915,7 +915,7 @@ static int CmdExchangeAPDU(bool chainingin, uint8_t *datain, int datainlen, bool
*chainingout = false; *chainingout = false;
if (activateField) { if (activateField) {
// select with no disconnect and set g_frame_len // select with no disconnect and set gs_frame_len
int selres = SelectCard14443A_4(false, true, NULL); int selres = SelectCard14443A_4(false, true, NULL);
if (selres != PM3_SUCCESS) if (selres != PM3_SUCCESS)
return selres; return selres;
@ -1002,14 +1002,14 @@ int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool lea
// 3 byte here - 1b framing header, 2b crc16 // 3 byte here - 1b framing header, 2b crc16
if (APDUInFramingEnable && if (APDUInFramingEnable &&
((g_frame_len && (datainlen > g_frame_len - 3)) || (datainlen > PM3_CMD_DATA_SIZE - 3))) { ((gs_frame_len && (datainlen > gs_frame_len - 3)) || (datainlen > PM3_CMD_DATA_SIZE - 3))) {
int clen = 0; int clen = 0;
bool vActivateField = activateField; bool vActivateField = activateField;
do { do {
int vlen = MIN(g_frame_len - 3, datainlen - clen); int vlen = MIN(gs_frame_len - 3, datainlen - clen);
bool chainBlockNotLast = ((clen + vlen) < datainlen); bool chainBlockNotLast = ((clen + vlen) < datainlen);
*dataoutlen = 0; *dataoutlen = 0;

View file

@ -60,7 +60,7 @@
#include "cmdlfvisa2000.h" // for VISA2000 menu #include "cmdlfvisa2000.h" // for VISA2000 menu
#include "pm3_cmd.h" // for LF_CMDREAD_MAX_EXTRA_SYMBOLS #include "pm3_cmd.h" // for LF_CMDREAD_MAX_EXTRA_SYMBOLS
static bool g_lf_threshold_set = false; static bool gs_lf_threshold_set = false;
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
@ -578,7 +578,7 @@ int CmdLFConfig(const char *Cmd) {
config.divisor = LF_DIVISOR_125; config.divisor = LF_DIVISOR_125;
config.samples_to_skip = 0; config.samples_to_skip = 0;
config.trigger_threshold = 0; config.trigger_threshold = 0;
g_lf_threshold_set = false; gs_lf_threshold_set = false;
} }
if (use_125) if (use_125)
@ -621,7 +621,7 @@ int CmdLFConfig(const char *Cmd) {
if (trigg > -1) { if (trigg > -1) {
config.trigger_threshold = trigg; config.trigger_threshold = trigg;
g_lf_threshold_set = (config.trigger_threshold > 0); gs_lf_threshold_set = (config.trigger_threshold > 0);
} }
config.samples_to_skip = skip; config.samples_to_skip = skip;
@ -643,7 +643,7 @@ int lf_read(bool verbose, uint32_t samples) {
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_LF_ACQ_RAW_ADC, (uint8_t *)&payload, sizeof(payload)); SendCommandNG(CMD_LF_ACQ_RAW_ADC, (uint8_t *)&payload, sizeof(payload));
PacketResponseNG resp; PacketResponseNG resp;
if (g_lf_threshold_set) { if (gs_lf_threshold_set) {
WaitForResponse(CMD_LF_ACQ_RAW_ADC, &resp); WaitForResponse(CMD_LF_ACQ_RAW_ADC, &resp);
} else { } else {
if (!WaitForResponseTimeout(CMD_LF_ACQ_RAW_ADC, &resp, 2500)) { if (!WaitForResponseTimeout(CMD_LF_ACQ_RAW_ADC, &resp, 2500)) {
@ -709,7 +709,7 @@ int lf_sniff(bool verbose, uint32_t samples) {
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_LF_SNIFF_RAW_ADC, (uint8_t *)&payload, sizeof(payload)); SendCommandNG(CMD_LF_SNIFF_RAW_ADC, (uint8_t *)&payload, sizeof(payload));
PacketResponseNG resp; PacketResponseNG resp;
if (g_lf_threshold_set) { if (gs_lf_threshold_set) {
WaitForResponse(CMD_LF_SNIFF_RAW_ADC, &resp); WaitForResponse(CMD_LF_SNIFF_RAW_ADC, &resp);
} else { } else {
if (!WaitForResponseTimeout(CMD_LF_SNIFF_RAW_ADC, &resp, 2500)) { if (!WaitForResponseTimeout(CMD_LF_SNIFF_RAW_ADC, &resp, 2500)) {

View file

@ -35,7 +35,7 @@
#include "cliparser.h" #include "cliparser.h"
#include "cmdhw.h" #include "cmdhw.h"
static uint64_t g_em410xid = 0; static uint64_t gs_em410xid = 0;
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
/* Read the ID of an EM410x tag. /* Read the ID of an EM410x tag.
@ -273,7 +273,7 @@ int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo) {
} }
printEM410x(*hi, *lo, verbose, ans); printEM410x(*hi, *lo, verbose, ans);
g_em410xid = *lo; gs_em410xid = *lo;
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -407,7 +407,7 @@ static int CmdEM410xReader(const char *Cmd) {
lf_read(false, 12288); lf_read(false, 12288);
AskEm410xDemod(clk, invert, max_err, max_len, amplify, &hi, &lo, verbose); AskEm410xDemod(clk, invert, max_err, max_len, amplify, &hi, &lo, verbose);
if (break_first && g_em410xid != 0) { if (break_first && gs_em410xid != 0) {
break; break;
} }
} while (cm && !kbd_enter_pressed()); } while (cm && !kbd_enter_pressed());
@ -615,9 +615,9 @@ static int CmdEM410xSpoof(const char *Cmd) {
CLIParserFree(ctx); CLIParserFree(ctx);
// loops if the captured ID was in XL-format. // loops if the captured ID was in XL-format.
g_em410xid = 0; gs_em410xid = 0;
CmdEM410xReader("-b@"); CmdEM410xReader("-b@");
PrintAndLogEx(SUCCESS, "Replaying captured EM Tag ID "_YELLOW_("%010" PRIx64), g_em410xid); PrintAndLogEx(SUCCESS, "Replaying captured EM Tag ID "_YELLOW_("%010" PRIx64), gs_em410xid);
CmdLFSim(""); CmdLFSim("");
return PM3_SUCCESS; return PM3_SUCCESS;
} }

View file

@ -26,8 +26,8 @@
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
// trace pointer // trace pointer
static uint8_t *g_trace; static uint8_t *gs_trace;
static long g_traceLen = 0; static long gs_traceLen = 0;
static bool is_last_record(uint16_t tracepos, uint16_t traceLen) { static bool is_last_record(uint16_t tracepos, uint16_t traceLen) {
return ((tracepos + TRACELOG_HDR_LEN) >= traceLen); return ((tracepos + TRACELOG_HDR_LEN) >= traceLen);
@ -503,13 +503,13 @@ static int download_trace(void) {
} }
// reserve some space. // reserve some space.
if (g_trace) if (gs_trace)
free(g_trace); free(gs_trace);
g_traceLen = 0; gs_traceLen = 0;
g_trace = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t)); gs_trace = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
if (g_trace == NULL) { if (gs_trace == NULL) {
PrintAndLogEx(FAILED, "Cannot allocate memory for trace"); PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
return PM3_EMALLOC; return PM3_EMALLOC;
} }
@ -518,29 +518,29 @@ static int download_trace(void) {
// Query for the size of the trace, downloading PM3_CMD_DATA_SIZE // Query for the size of the trace, downloading PM3_CMD_DATA_SIZE
PacketResponseNG response; PacketResponseNG response;
if (!GetFromDevice(BIG_BUF, g_trace, PM3_CMD_DATA_SIZE, 0, NULL, 0, &response, 4000, true)) { if (!GetFromDevice(BIG_BUF, gs_trace, PM3_CMD_DATA_SIZE, 0, NULL, 0, &response, 4000, true)) {
PrintAndLogEx(WARNING, "timeout while waiting for reply."); PrintAndLogEx(WARNING, "timeout while waiting for reply.");
free(g_trace); free(gs_trace);
g_trace = NULL; gs_trace = NULL;
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
g_traceLen = response.oldarg[2]; gs_traceLen = response.oldarg[2];
// if tracelog buffer was larger and we need to download more. // if tracelog buffer was larger and we need to download more.
if (g_traceLen > PM3_CMD_DATA_SIZE) { if (gs_traceLen > PM3_CMD_DATA_SIZE) {
free(g_trace); free(gs_trace);
g_trace = calloc(g_traceLen, sizeof(uint8_t)); gs_trace = calloc(gs_traceLen, sizeof(uint8_t));
if (g_trace == NULL) { if (gs_trace == NULL) {
PrintAndLogEx(FAILED, "Cannot allocate memory for trace"); PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
return PM3_EMALLOC; return PM3_EMALLOC;
} }
if (!GetFromDevice(BIG_BUF, g_trace, g_traceLen, 0, NULL, 0, NULL, 2500, false)) { if (!GetFromDevice(BIG_BUF, gs_trace, gs_traceLen, 0, NULL, 0, NULL, 2500, false)) {
PrintAndLogEx(WARNING, "command execution time out"); PrintAndLogEx(WARNING, "command execution time out");
free(g_trace); free(gs_trace);
g_trace = NULL; gs_trace = NULL;
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
} }
@ -579,20 +579,20 @@ static int CmdTraceLoad(const char *Cmd) {
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen); CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
CLIParserFree(ctx); CLIParserFree(ctx);
if (g_trace) { if (gs_trace) {
free(g_trace); free(gs_trace);
g_trace = NULL; gs_trace = NULL;
} }
size_t len = 0; size_t len = 0;
if (loadFile_safe(filename, ".trace", (void **)&g_trace, &len) != PM3_SUCCESS) { if (loadFile_safe(filename, ".trace", (void **)&gs_trace, &len) != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Could not open file " _YELLOW_("%s"), filename); PrintAndLogEx(FAILED, "Could not open file " _YELLOW_("%s"), filename);
return PM3_EIO; return PM3_EIO;
} }
g_traceLen = (long)len; gs_traceLen = (long)len;
PrintAndLogEx(SUCCESS, "Recorded Activity (TraceLen = " _YELLOW_("%lu") " bytes)", g_traceLen); PrintAndLogEx(SUCCESS, "Recorded Activity (TraceLen = " _YELLOW_("%lu") " bytes)", gs_traceLen);
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -617,15 +617,15 @@ static int CmdTraceSave(const char *Cmd) {
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen); CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
CLIParserFree(ctx); CLIParserFree(ctx);
if (g_traceLen == 0) { if (gs_traceLen == 0) {
download_trace(); download_trace();
if (g_traceLen == 0) { if (gs_traceLen == 0) {
PrintAndLogEx(WARNING, "trace is empty, nothing to save"); PrintAndLogEx(WARNING, "trace is empty, nothing to save");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
} }
saveFile(filename, ".trace", g_trace, g_traceLen); saveFile(filename, ".trace", gs_trace, gs_traceLen);
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -756,13 +756,13 @@ int CmdTraceList(const char *Cmd) {
if (use_buffer == false) { if (use_buffer == false) {
download_trace(); download_trace();
} else if (g_traceLen == 0) { } else if (gs_traceLen == 0) {
PrintAndLogEx(FAILED, "You requested a trace list in offline mode but there is no trace, consider using 'trace load' or removing parameter '-1'"); PrintAndLogEx(FAILED, "You requested a trace list in offline mode but there is no trace, consider using 'trace load' or removing parameter '-1'");
return PM3_EINVARG; return PM3_EINVARG;
} }
PrintAndLogEx(SUCCESS, "Recorded activity (trace len = " _YELLOW_("%lu") " bytes)", g_traceLen); PrintAndLogEx(SUCCESS, "Recorded activity (trace len = " _YELLOW_("%lu") " bytes)", gs_traceLen);
if (g_traceLen == 0) { if (gs_traceLen == 0) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -770,12 +770,12 @@ int CmdTraceList(const char *Cmd) {
/* /*
if (protocol == FELICA) { if (protocol == FELICA) {
printFelica(g_traceLen, g_trace); printFelica(gs_traceLen, gs_trace);
} */ } */
if (show_hex) { if (show_hex) {
while (tracepos < g_traceLen) { while (tracepos < gs_traceLen) {
tracepos = printHexLine(tracepos, g_traceLen, g_trace, protocol); tracepos = printHexLine(tracepos, gs_traceLen, gs_trace, protocol);
} }
} else { } else {
@ -877,8 +877,8 @@ int CmdTraceList(const char *Cmd) {
prev_EOT = &previous_EOT; prev_EOT = &previous_EOT;
} }
while (tracepos < g_traceLen) { while (tracepos < gs_traceLen) {
tracepos = printTraceLine(tracepos, g_traceLen, g_trace, protocol, show_wait_cycles, mark_crc, prev_EOT, use_us, dicKeys, dicKeysCount); tracepos = printTraceLine(tracepos, gs_traceLen, gs_trace, protocol, show_wait_cycles, mark_crc, prev_EOT, use_us, dicKeys, dicKeysCount);
if (kbd_enter_pressed()) if (kbd_enter_pressed())
break; break;

View file

@ -404,9 +404,9 @@ static int wait_for_ack(PacketResponseNG *ack) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
static bool g_printed_msg = false; static bool gs_printed_msg = false;
static void flash_suggest_update_bootloader(void) { static void flash_suggest_update_bootloader(void) {
if (g_printed_msg) if (gs_printed_msg)
return; return;
PrintAndLogEx(ERR, _RED_("It is recommended that you first" _YELLOW_(" update your bootloader") _RED_(" alone,"))); PrintAndLogEx(ERR, _RED_("It is recommended that you first" _YELLOW_(" update your bootloader") _RED_(" alone,")));
@ -416,7 +416,7 @@ static void flash_suggest_update_bootloader(void) {
PrintAndLogEx(ERR, " 2) ./pm3-flash-all"); PrintAndLogEx(ERR, " 2) ./pm3-flash-all");
PrintAndLogEx(ERR, " 3) ./pm3"); PrintAndLogEx(ERR, " 3) ./pm3");
PrintAndLogEx(INFO, "--------------------------------------------------------"); PrintAndLogEx(INFO, "--------------------------------------------------------");
g_printed_msg = true; gs_printed_msg = true;
} }
static void flash_suggest_update_flasher(void) { static void flash_suggest_update_flasher(void) {

View file

@ -38,8 +38,8 @@
extern "C" int preferences_save(void); extern "C" int preferences_save(void);
static int s_Buff[MAX_GRAPH_TRACE_LEN]; static int s_Buff[MAX_GRAPH_TRACE_LEN];
static bool g_useOverlays = false; static bool gs_useOverlays = false;
static int g_absVMax = 0; static int gs_absVMax = 0;
static uint32_t startMax; // Maximum offset in the graph (right side of graph) static uint32_t startMax; // Maximum offset in the graph (right side of graph)
static uint32_t PageWidth; // How many samples are currently visible on this 'page' / graph static uint32_t PageWidth; // How many samples are currently visible on this 'page' / graph
static int unlockStart = 0; static int unlockStart = 0;
@ -302,28 +302,28 @@ void ProxWidget::stickOperation() {
void ProxWidget::vchange_autocorr(int v) { void ProxWidget::vchange_autocorr(int v) {
int ans = AutoCorrelate(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, true, false); int ans = AutoCorrelate(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, true, false);
if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans); if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans);
g_useOverlays = true; gs_useOverlays = true;
RepaintGraphWindow(); RepaintGraphWindow();
} }
void ProxWidget::vchange_askedge(int v) { void ProxWidget::vchange_askedge(int v) {
//extern int AskEdgeDetect(const int *in, int *out, int len, int threshold); //extern int AskEdgeDetect(const int *in, int *out, int len, int threshold);
int ans = AskEdgeDetect(g_GraphBuffer, s_Buff, g_GraphTraceLen, v); int ans = AskEdgeDetect(g_GraphBuffer, s_Buff, g_GraphTraceLen, v);
if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans); if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans);
g_useOverlays = true; gs_useOverlays = true;
RepaintGraphWindow(); RepaintGraphWindow();
} }
void ProxWidget::vchange_dthr_up(int v) { void ProxWidget::vchange_dthr_up(int v) {
int down = opsController->horizontalSlider_dirthr_down->value(); int down = opsController->horizontalSlider_dirthr_down->value();
directionalThreshold(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, down); directionalThreshold(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, down);
//printf("vchange_dthr_up(%d)", v); //printf("vchange_dthr_up(%d)", v);
g_useOverlays = true; gs_useOverlays = true;
RepaintGraphWindow(); RepaintGraphWindow();
} }
void ProxWidget::vchange_dthr_down(int v) { void ProxWidget::vchange_dthr_down(int v) {
//printf("vchange_dthr_down(%d)", v); //printf("vchange_dthr_down(%d)", v);
int up = opsController->horizontalSlider_dirthr_up->value(); int up = opsController->horizontalSlider_dirthr_up->value();
directionalThreshold(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, up); directionalThreshold(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, up);
g_useOverlays = true; gs_useOverlays = true;
RepaintGraphWindow(); RepaintGraphWindow();
} }
@ -415,7 +415,7 @@ ProxWidget::~ProxWidget(void) {
void ProxWidget::closeEvent(QCloseEvent *event) { void ProxWidget::closeEvent(QCloseEvent *event) {
event->ignore(); event->ignore();
this->hide(); this->hide();
g_useOverlays = false; gs_useOverlays = false;
} }
void ProxWidget::hideEvent(QHideEvent *event) { void ProxWidget::hideEvent(QHideEvent *event) {
controlWidget->hide(); controlWidget->hide();
@ -504,10 +504,10 @@ void Plot::setMaxAndStart(int *buffer, size_t len, QRect plotRect) {
if (v > vMax) vMax = v; if (v > vMax) vMax = v;
} }
g_absVMax = 0; gs_absVMax = 0;
if (fabs((double) vMin) > g_absVMax) g_absVMax = (int)fabs((double) vMin); if (fabs((double) vMin) > gs_absVMax) gs_absVMax = (int)fabs((double) vMin);
if (fabs((double) vMax) > g_absVMax) g_absVMax = (int)fabs((double) vMax); if (fabs((double) vMax) > gs_absVMax) gs_absVMax = (int)fabs((double) vMax);
g_absVMax = (int)(g_absVMax * 1.25 + 1); gs_absVMax = (int)(gs_absVMax * 1.25 + 1);
} }
void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum, uint32_t plotOffset) { void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum, uint32_t plotOffset) {
@ -572,14 +572,14 @@ void Plot::PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRe
int64_t vMean = 0; int64_t vMean = 0;
uint32_t i = 0; uint32_t i = 0;
int x = xCoordOf(g_GraphStart, plotRect); int x = xCoordOf(g_GraphStart, plotRect);
int y = yCoordOf(buffer[g_GraphStart], plotRect, g_absVMax); int y = yCoordOf(buffer[g_GraphStart], plotRect, gs_absVMax);
penPath.moveTo(x, y); penPath.moveTo(x, y);
for (i = g_GraphStart; i < len && xCoordOf(i, plotRect) < plotRect.right(); i++) { for (i = g_GraphStart; i < len && xCoordOf(i, plotRect) < plotRect.right(); i++) {
x = xCoordOf(i, plotRect); x = xCoordOf(i, plotRect);
v = buffer[i]; v = buffer[i];
y = yCoordOf(v, plotRect, g_absVMax); y = yCoordOf(v, plotRect, gs_absVMax);
penPath.lineTo(x, y); penPath.lineTo(x, y);
@ -601,7 +601,7 @@ void Plot::PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRe
int xo = 5 + (graphNum * 40); int xo = 5 + (graphNum * 40);
painter->drawLine(xo, plotRect.top(), xo, plotRect.bottom()); painter->drawLine(xo, plotRect.top(), xo, plotRect.bottom());
int vMarkers = (g_absVMax - (g_absVMax % 10)) / 5; int vMarkers = (gs_absVMax - (gs_absVMax % 10)) / 5;
int minYDist = 40; // Minimum pixel-distance between markers int minYDist = 40; // Minimum pixel-distance between markers
char yLbl[20]; char yLbl[20];
@ -609,9 +609,9 @@ void Plot::PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRe
int n = 0; int n = 0;
int lasty0 = 65535; int lasty0 = 65535;
for (v = vMarkers; yCoordOf(v, plotRect, g_absVMax) > plotRect.top() && n < 20; v += vMarkers, n++) { for (v = vMarkers; yCoordOf(v, plotRect, gs_absVMax) > plotRect.top() && n < 20; v += vMarkers, n++) {
int y0 = yCoordOf(v, plotRect, g_absVMax); int y0 = yCoordOf(v, plotRect, gs_absVMax);
int y1 = yCoordOf(-v, plotRect, g_absVMax); int y1 = yCoordOf(-v, plotRect, gs_absVMax);
if (lasty0 - y0 < minYDist) continue; if (lasty0 - y0 < minYDist) continue;
@ -662,11 +662,11 @@ void Plot::plotGridLines(QPainter *painter, QRect r) {
} }
if (g_PlotGridY > 0) { if (g_PlotGridY > 0) {
for (i = 0; yCoordOf(i, r, g_absVMax) > r.top(); i += grid_delta_y) { for (i = 0; yCoordOf(i, r, gs_absVMax) > r.top(); i += grid_delta_y) {
// line above mid // line above mid
painter->drawLine(r.left(), yCoordOf(i, r, g_absVMax), r.right(), yCoordOf(i, r, g_absVMax)); painter->drawLine(r.left(), yCoordOf(i, r, gs_absVMax), r.right(), yCoordOf(i, r, gs_absVMax));
// line below mid // line below mid
painter->drawLine(r.left(), yCoordOf(-i, r, g_absVMax), r.right(), yCoordOf(-i, r, g_absVMax)); painter->drawLine(r.left(), yCoordOf(-i, r, gs_absVMax), r.right(), yCoordOf(-i, r, gs_absVMax));
} }
} }
} }
@ -714,7 +714,7 @@ void Plot::paintEvent(QPaintEvent *event) {
if (g_DemodBufferLen > 8) { if (g_DemodBufferLen > 8) {
PlotDemod(g_DemodBuffer, g_DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx); PlotDemod(g_DemodBuffer, g_DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx);
} }
if (g_useOverlays) { if (gs_useOverlays) {
//init graph variables //init graph variables
setMaxAndStart(s_Buff, g_GraphTraceLen, plotRect); setMaxAndStart(s_Buff, g_GraphTraceLen, plotRect);
PlotGraph(s_Buff, g_GraphTraceLen, plotRect, infoRect, &painter, 1); PlotGraph(s_Buff, g_GraphTraceLen, plotRect, infoRect, &painter, 1);
@ -790,7 +790,7 @@ Plot::Plot(QWidget *parent) : QWidget(parent), g_GraphPixelsPerPoint(1) {
void Plot::closeEvent(QCloseEvent *event) { void Plot::closeEvent(QCloseEvent *event) {
event->ignore(); event->ignore();
this->hide(); this->hide();
g_useOverlays = false; gs_useOverlays = false;
} }
void Plot::Zoom(double factor, uint32_t refX) { void Plot::Zoom(double factor, uint32_t refX) {