inc/MainWindow.h
author sl
Thu, 22 May 2014 22:36:43 +0200
changeset 24 c6b5c552980a
parent 23 d4e164906a1b
child 25 233a997193b8
permissions -rw-r--r--
Draft implementation of our bitmap to display format.
     1 
     2 
     3 #ifndef MAIN_WINDOW_H
     4 #define MAIN_WINDOW_H
     5 
     6 #include <fx.h>
     7 #include "hidapi.h"
     8 #include "mac_support.h"
     9 #include <string.h>
    10 #include <stdlib.h>
    11 #include <limits.h>
    12 #include "FutabaVfd.h"
    13 
    14 #ifdef _WIN32
    15 // Thanks Microsoft, but I know how to use strncpy().
    16 #pragma warning(disable:4996)
    17 #endif
    18 
    19 class MainWindow : public FXMainWindow {
    20     FXDECLARE(MainWindow)
    21 
    22 public:
    23     enum {
    24         ID_FIRST = FXMainWindow::ID_LAST,
    25         ID_CONNECT,
    26         ID_DISCONNECT,
    27         ID_RESCAN,
    28         ID_SEND_OUTPUT_REPORT,
    29         ID_SEND_FEATURE_REPORT,
    30         ID_GET_FEATURE_REPORT,
    31         ID_CLEAR,
    32         ID_TIMER,
    33         ID_MAC_TIMER,
    34         ID_FUTABA_CLEAR_DISPLAY,
    35         ID_FUTABA_DIMMING,
    36         ID_FUTABA_DISPLAY_DATA_INPUT,
    37         ID_FUTABA_READ_ID,
    38         ID_FUTABA_READ_FIRMWARE_REVISION,
    39         ID_FUTABA_POWER_SUPPLY_MONITOR,
    40         ID_FUTABA_SET_PIXEL,
    41         ID_FUTABA_RESET_PIXEL,
    42         ID_FUTABA_SET_ALL_PIXELS,
    43         ID_FUTABA_SET_DISPLAY_POSITION,
    44 		ID_FUTABA_TOGGLE_OFF_SCREEN_MODE,
    45         ID_SELECT_FONT,
    46         ID_LAST
    47     };
    48 
    49     size_t getDataFromTextField(FXTextField *tf, char *buf, size_t len);
    50     int getLengthFromTextField(FXTextField *tf);
    51 
    52 protected:
    53     MainWindow() {};
    54 public:
    55     MainWindow(FXApp *a);
    56     ~MainWindow();
    57     virtual void create();
    58 
    59     long onConnect(FXObject *sender, FXSelector sel, void *ptr);
    60     long onDisconnect(FXObject *sender, FXSelector sel, void *ptr);
    61     long onScan(FXObject *sender, FXSelector sel, void *ptr);
    62     long onSendOutputReport(FXObject *sender, FXSelector sel, void *ptr);
    63     long onSendFeatureReport(FXObject *sender, FXSelector sel, void *ptr);
    64     long onGetFeatureReport(FXObject *sender, FXSelector sel, void *ptr);
    65     long onClear(FXObject *sender, FXSelector sel, void *ptr);
    66     //
    67     long onFutabaClearDisplay(FXObject *sender, FXSelector sel, void *ptr);
    68     long onFutabaDimming(FXObject *sender, FXSelector sel, void *ptr);
    69     long onFutabaDisplayDataInput(FXObject *sender, FXSelector sel, void *ptr);
    70     long onFutabaReadId(FXObject *sender, FXSelector sel, void *ptr);
    71     long onFutabaReadFirmwareRevision(FXObject *sender, FXSelector sel, void *ptr);
    72     long onFutabaPowerSupplyMonitor(FXObject *sender, FXSelector sel, void *ptr);
    73     long onFutabaSetAllPixels(FXObject *sender, FXSelector sel, void *ptr);
    74     long onFutabaSetPixel(FXObject *sender, FXSelector sel, void *ptr);
    75     long onFutabaResetPixel(FXObject *sender, FXSelector sel, void *ptr);
    76     long onFutabaSetDisplayPosition(FXObject *sender, FXSelector sel, void *ptr);
    77 	long onFutabaToggleOffScreenMode(FXObject *sender, FXSelector sel, void *ptr);
    78     //
    79     long onSelectFont(FXObject *sender, FXSelector sel, void *ptr);
    80     //
    81     long onTimeout(FXObject *sender, FXSelector sel, void *ptr);
    82     long onMacTimeout(FXObject *sender, FXSelector sel, void *ptr);
    83     
    84 private:
    85     void SetConnectedStates();
    86     bool IsConnected();
    87 
    88 private:
    89     FXList *device_list;
    90     FXButton *connect_button;
    91     FXButton *disconnect_button;
    92     FXButton *rescan_button;
    93     FXButton *output_button;
    94     FXLabel *connected_label;
    95     FXTextField *output_text;
    96     FXTextField *output_len;
    97     FXButton *feature_button;
    98     FXButton *get_feature_button;
    99     FXTextField *feature_text;
   100     FXTextField *feature_len;
   101     FXTextField *get_feature_text;
   102     FXText *input_text;
   103     FXFont *title_font;
   104     //Futaba VFD control
   105     FXButton *iButtonClearDisplay;
   106     FXButton *iButtonBrightness;
   107     FXButton *iButtonDisplayDataInput;
   108     FXButton *iButtonReadId;
   109     FXButton *iButtonReadFirmwareRevision;
   110     FXButton *iButtonPowerSupplyMonitor;
   111     FXTextField *iTextFieldX;
   112     FXTextField *iTextFieldY;
   113     FXButton *iButtonSetPixel;
   114     FXButton *iButtonResetPixel;
   115     FXButton *iButtonSetAllPixels;
   116     FXButton *iButtonSetDisplayPosition;
   117 	FXButton *iButtonToggleOffScreenMode;
   118     //Font
   119     FXButton *iButtonSelectFont;
   120 
   121     unsigned char* iOutputReportBuffer;
   122     unsigned char iBrightness; //Current VFD dimming
   123     FXFontDesc iCurrentFontDesc;
   124     FXFont* iCurrentFont;
   125     FXTGAImage* iFontImage;
   126 	///Used the following to convert our bitmap into display format
   127 	unsigned char* iPixelBuffer;
   128 
   129     struct hid_device_info *devices;
   130     hid_device *connected_device;
   131 
   132 	//Futaba
   133 	GP1212A01A iVfd01;
   134 
   135 };
   136 
   137 #endif //