From 0259dec75bd7b43b0d74fe90ad061f74b5177c86 Mon Sep 17 00:00:00 2001 From: Attila Veghelyi Date: Wed, 16 Oct 2024 16:58:00 +0200 Subject: Use common functions from one file --- common.h | 1 + common_functions.c | 14 +++++++++----- common_functions.h | 19 +++++++++++-------- op.c | 10 +++++++--- opgui.c | 15 ++++++++------- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/common.h b/common.h index ba105e7..6dfe998 100644 --- a/common.h +++ b/common.h @@ -57,6 +57,7 @@ typedef unsigned char BYTE; extern int statusID; extern GtkWidget *status_bar; void PrintMessage(const char *msg); + void MsgBox(const char* msg); #else #define _APPNAME "OP" diff --git a/common_functions.c b/common_functions.c index 388b4b0..2c042cb 100644 --- a/common_functions.c +++ b/common_functions.c @@ -6,13 +6,15 @@ #include "progAVR.h" -#define FALSE 0 -#define TRUE (!0) +#ifndef FALSE + #define FALSE 0 +#endif +#ifndef TRUE + #define TRUE (!0) +#endif #define MinDly 0 -void ProgID(); -int CheckS1(); char** strings; //!localized strings int saveLog=0,programID=0,load_osccal=0,load_BKosccal=0; int use_osccal=1,use_BKosccal=0; @@ -30,11 +32,12 @@ unsigned char *memCODE=0,*memEE=0,memID[64],memCONFIG[48],memUSERID[8]; double hvreg=0; int RWstop=0; int forceConfig=0; -char str[4096]; +char str[4096]=""; void printMsg(const char* msg) { #ifdef OPGUI + GtkWidget* b_V33check; MsgBox(msg); #else PrintMessage(msg); @@ -50,6 +53,7 @@ void printMsg(const char* msg) struct hiddev_usage_ref_multi ref_multi_i,ref_multi_u; #endif unsigned char bufferU[128],bufferI[128]; + char path[512]=""; #else //Windows unsigned char bufferU0[128],bufferI0[128]; unsigned char *bufferU,*bufferI; diff --git a/common_functions.h b/common_functions.h index 8521dd8..5855a0a 100644 --- a/common_functions.h +++ b/common_functions.h @@ -1,17 +1,20 @@ #ifndef COMMON_FUNCTIONS_H #define COMMON_FUNCTIONS_H -extern int skipV33check=0; -extern char loadfileEE[512]="",savefileEE[512]=""; -extern int vid=0x1209,pid=0x5432; -extern int DeviceDetected=0; -extern int new_vid=0x1209,new_pid=0x5432; -extern int old_vid=0x04D8,old_pid=0x0100; +extern int skipV33check; +extern int vid,pid; +extern int DeviceDetected; +static const int new_vid=0x1209,new_pid=0x5432; +static const int old_vid=0x04D8,old_pid=0x0100; #if !defined _WIN32 && !defined __CYGWIN__ //Linux - extern char path[512]=""; + extern char path[512]; #endif #ifdef OPGUI - extern GtkWidget * b_V33check; + extern GtkWidget* b_V33check; #endif +extern char str[4096]; + +void ProgID(void); +int CheckS1(void); #endif // COMMON_FUNCTIONS_H diff --git a/op.c b/op.c index bc32f94..032e068 100644 --- a/op.c +++ b/op.c @@ -47,9 +47,6 @@ int kbhit() #include "conio.h" #endif -int info=0; -int devType=0x10000; -char dev[64]=""; void msDelay(double delay); void TestHw(); @@ -57,6 +54,13 @@ int StartHVReg(double V); void DisplayEE(); int FindDevice(); +char loadfileEE[512]="",savefileEE[512]=""; +int info=0; +int vid=0x1209,pid=0x5432; +int DeviceDetected=0; +int skipV33check=0; +char dev[64]=""; +int devType=0x10000; int main (int argc, char **argv) { diff --git a/opgui.c b/opgui.c index cf8255f..c93dc86 100644 --- a/opgui.c +++ b/opgui.c @@ -29,7 +29,6 @@ #include "deviceRW.h" #include "fileIO.h" #include "progAVR.h" -#include #define MAXLINES 600 #define CONFIG_FILE "opgui.ini" @@ -44,6 +43,13 @@ void PrintMessageI2C(const char *msg); void ShowContext(); int FindDevice(int vid,int pid); void TestHw(); +int cmdline=0; +int vid=0x1209,pid=0x5432; +int DeviceDetected=0; +int IOTimer=0; +int skipV33check=0; +int waitS1=0,waitingS1=0; +int progress=0; #ifdef DEBUG int addrDebug=0; @@ -105,6 +111,7 @@ GtkWidget * VDD_ON; GtkWidget * b_io_active; GtkWidget * commandSend; GtkWidget * commandTransfer; +GtkWidget * b_V33check; GtkWidget * Hex_entry; GtkWidget * Address_entry; GtkWidget * Data_entry; @@ -151,7 +158,6 @@ int ee = 0; int readRes=0; char dev[64]=""; int devType=-1; -char str[4096]=""; char* cur_path=0; char* cur_pathEE=0; enum dev_column_t { @@ -176,11 +182,6 @@ char *groupNames[NUM_GROUPS] = { }; char *GROUP_ALL="*"; -int progress=0; -int waitS1=0,waitingS1=0; -int IOTimer=0; -int cmdline=0; - /// ///Exit gint delete_event( GtkWidget *widget,GdkEvent *event,gpointer data ) -- cgit v1.2.3-54-g00ecf