diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gadc/gadc_gadc.c (renamed from src/gadc/gadc.c) | 4 | ||||
-rw-r--r-- | src/gadc/sys_make.mk | 2 | ||||
-rw-r--r-- | src/gaudio/gaudio_gaudio.c (renamed from src/gaudio/gaudio.c) | 6 | ||||
-rw-r--r-- | src/gaudio/sys_make.mk | 2 | ||||
-rw-r--r-- | src/gdisp/fonts/build_fonts.sh | 2 | ||||
-rw-r--r-- | src/gdisp/fonts/fonts.h | 34 | ||||
-rw-r--r-- | src/gdisp/gdisp_colors.h (renamed from src/gdisp/colors.h) | 2 | ||||
-rw-r--r-- | src/gdisp/gdisp_fonts.c (renamed from src/gdisp/fonts.c) | 4 | ||||
-rw-r--r-- | src/gdisp/gdisp_gdisp.c (renamed from src/gdisp/gdisp.c) | 6 | ||||
-rw-r--r-- | src/gdisp/gdisp_image.c (renamed from src/gdisp/image.c) | 2 | ||||
-rw-r--r-- | src/gdisp/gdisp_image.h (renamed from src/gdisp/image.h) | 2 | ||||
-rw-r--r-- | src/gdisp/gdisp_image_bmp.c (renamed from src/gdisp/image_bmp.c) | 0 | ||||
-rw-r--r-- | src/gdisp/gdisp_image_gif.c (renamed from src/gdisp/image_gif.c) | 0 | ||||
-rw-r--r-- | src/gdisp/gdisp_image_jpg.c (renamed from src/gdisp/image_jpg.c) | 0 | ||||
-rw-r--r-- | src/gdisp/gdisp_image_native.c (renamed from src/gdisp/image_native.c) | 0 | ||||
-rw-r--r-- | src/gdisp/gdisp_image_png.c (renamed from src/gdisp/image_png.c) | 0 | ||||
-rw-r--r-- | src/gdisp/sys_defs.h | 4 | ||||
-rw-r--r-- | src/gdisp/sys_make.mk | 16 | ||||
-rw-r--r-- | src/gevent/gevent_gevent.c (renamed from src/gevent/gevent.c) | 2 | ||||
-rw-r--r-- | src/gevent/sys_make.mk | 2 | ||||
-rw-r--r-- | src/gfile/gfile_fatfs_diskio_chibios.c (renamed from src/gfile/fatfs_chibios_diskio.c) | 8 | ||||
-rw-r--r-- | src/gfile/gfile_fatfs_wrapper.c (renamed from src/gfile/fatfs_wrapper.c) | 4 | ||||
-rw-r--r-- | src/gfile/gfile_fatfs_wrapper.h (renamed from src/gfile/fatfs_wrapper.h) | 2 | ||||
-rw-r--r-- | src/gfile/gfile_fs_chibios.c (renamed from src/gfile/inc_chibiosfs.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_fs_fatfs.c (renamed from src/gfile/inc_fatfs.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_fs_mem.c (renamed from src/gfile/inc_memfs.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_fs_native.c (renamed from src/gfile/inc_nativefs.c) | 1 | ||||
-rw-r--r-- | src/gfile/gfile_fs_petitfs.c (renamed from src/gfile/inc_petitfs.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_fs_ram.c (renamed from src/gfile/inc_ramfs.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_fs_rom.c (renamed from src/gfile/inc_romfs.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_fs_strings.c (renamed from src/gfile/inc_strings.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_gfile.c (renamed from src/gfile/gfile.c) | 2 | ||||
-rw-r--r-- | src/gfile/gfile_petitfs_diskio_chibios.c (renamed from src/gfile/petitfs_chibios_diskio.c) | 8 | ||||
-rw-r--r-- | src/gfile/gfile_petitfs_wrapper.c (renamed from src/gfile/petitfs_wrapper.c) | 4 | ||||
-rw-r--r-- | src/gfile/gfile_petitfs_wrapper.h (renamed from src/gfile/petitfs_wrapper.h) | 2 | ||||
-rw-r--r-- | src/gfile/gfile_printg.c (renamed from src/gfile/inc_printg.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_scang.c (renamed from src/gfile/inc_scang.c) | 0 | ||||
-rw-r--r-- | src/gfile/gfile_stdio.c (renamed from src/gfile/inc_stdio.c) | 0 | ||||
-rw-r--r-- | src/gfile/sys_make.mk | 32 | ||||
-rw-r--r-- | src/ginput/ginput_dial.c (renamed from src/ginput/dial.c) | 4 | ||||
-rw-r--r-- | src/ginput/ginput_dial.h (renamed from src/ginput/dial.h) | 2 | ||||
-rw-r--r-- | src/ginput/ginput_ginput.c (renamed from src/ginput/ginput.c) | 2 | ||||
-rw-r--r-- | src/ginput/ginput_keyboard.c (renamed from src/ginput/keyboard.c) | 46 | ||||
-rw-r--r-- | src/ginput/ginput_keyboard.h (renamed from src/ginput/keyboard.h) | 2 | ||||
-rw-r--r-- | src/ginput/ginput_mouse.c (renamed from src/ginput/mouse.c) | 4 | ||||
-rw-r--r-- | src/ginput/ginput_mouse.h (renamed from src/ginput/mouse.h) | 2 | ||||
-rw-r--r-- | src/ginput/ginput_toggle.c (renamed from src/ginput/toggle.c) | 312 | ||||
-rw-r--r-- | src/ginput/ginput_toggle.h (renamed from src/ginput/toggle.h) | 2 | ||||
-rw-r--r-- | src/ginput/sys_defs.h | 8 | ||||
-rw-r--r-- | src/ginput/sys_make.mk | 10 | ||||
-rw-r--r-- | src/gmisc/gmisc_arrayops.c (renamed from src/gmisc/arrayops.c) | 452 | ||||
-rw-r--r-- | src/gmisc/gmisc_gmisc.c (renamed from src/gmisc/gmisc.c) | 2 | ||||
-rw-r--r-- | src/gmisc/gmisc_trig.c (renamed from src/gmisc/trig.c) | 2 | ||||
-rw-r--r-- | src/gmisc/sys_make.mk | 6 | ||||
-rw-r--r-- | src/gqueue/gqueue_gqueue.c (renamed from src/gqueue/gqueue.c) | 2 | ||||
-rw-r--r-- | src/gqueue/sys_make.mk | 2 | ||||
-rw-r--r-- | src/gtimer/gtimer_gtimer.c (renamed from src/gtimer/gtimer.c) | 476 | ||||
-rw-r--r-- | src/gtimer/sys_make.mk | 2 | ||||
-rw-r--r-- | src/gwin/gwin_button.c (renamed from src/gwin/button.c) | 30 | ||||
-rw-r--r-- | src/gwin/gwin_button.h (renamed from src/gwin/button.h) | 14 | ||||
-rw-r--r-- | src/gwin/gwin_checkbox.c (renamed from src/gwin/checkbox.c) | 6 | ||||
-rw-r--r-- | src/gwin/gwin_checkbox.h (renamed from src/gwin/checkbox.h) | 10 | ||||
-rw-r--r-- | src/gwin/gwin_class.h (renamed from src/gwin/class_gwin.h) | 18 | ||||
-rw-r--r-- | src/gwin/gwin_console.c (renamed from src/gwin/console.c) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_console.h (renamed from src/gwin/console.h) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_container.c (renamed from src/gwin/gcontainer.c) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_container.h (renamed from src/gwin/gcontainer.h) | 6 | ||||
-rw-r--r-- | src/gwin/gwin_frame.c (renamed from src/gwin/frame.c) | 9 | ||||
-rw-r--r-- | src/gwin/gwin_frame.h (renamed from src/gwin/frame.h) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_gl3d.c | 171 | ||||
-rw-r--r-- | src/gwin/gwin_gl3d.h | 70 | ||||
-rw-r--r-- | src/gwin/gwin_graph.c (renamed from src/gwin/graph.c) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_graph.h (renamed from src/gwin/graph.h) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_gwin.c (renamed from src/gwin/gwin.c) | 74 | ||||
-rw-r--r-- | src/gwin/gwin_image.c (renamed from src/gwin/gimage.c) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_image.h (renamed from src/gwin/gimage.h) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_label.c (renamed from src/gwin/label.c) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_label.h (renamed from src/gwin/label.h) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_list.c (renamed from src/gwin/list.c) | 6 | ||||
-rw-r--r-- | src/gwin/gwin_list.h (renamed from src/gwin/list.h) | 10 | ||||
-rw-r--r-- | src/gwin/gwin_progressbar.c (renamed from src/gwin/progressbar.c) | 4 | ||||
-rw-r--r-- | src/gwin/gwin_progressbar.h (renamed from src/gwin/progressbar.h) | 3 | ||||
-rw-r--r-- | src/gwin/gwin_radio.c (renamed from src/gwin/radio.c) | 6 | ||||
-rw-r--r-- | src/gwin/gwin_radio.h (renamed from src/gwin/radio.h) | 10 | ||||
-rw-r--r-- | src/gwin/gwin_slider.c (renamed from src/gwin/slider.c) | 6 | ||||
-rw-r--r-- | src/gwin/gwin_slider.h (renamed from src/gwin/slider.h) | 10 | ||||
-rw-r--r-- | src/gwin/gwin_widget.c (renamed from src/gwin/gwidget.c) | 25 | ||||
-rw-r--r-- | src/gwin/gwin_widget.h (renamed from src/gwin/gwidget.h) | 48 | ||||
-rw-r--r-- | src/gwin/gwin_wm.c (renamed from src/gwin/gwm.c) | 9 | ||||
-rw-r--r-- | src/gwin/sys_defs.h | 15 | ||||
-rw-r--r-- | src/gwin/sys_make.mk | 34 | ||||
-rw-r--r-- | src/gwin/sys_options.h | 7 |
92 files changed, 1223 insertions, 909 deletions
diff --git a/src/gadc/gadc.c b/src/gadc/gadc_gadc.c index d307519b..5ac8e53c 100644 --- a/src/gadc/gadc.c +++ b/src/gadc/gadc_gadc.c @@ -6,7 +6,7 @@ */ /** - * @file src/gadc/gadc.c + * @file src/gadc/gadc_gadc.c * @brief GADC sub-system code. * * @addtogroup GADC @@ -17,7 +17,7 @@ #if GFX_USE_GADC /* Include the driver defines */ -#include "src/gadc/driver.h" +#include "driver.h" #if GADC_MAX_HIGH_SPEED_SAMPLERATE > GADC_MAX_SAMPLE_FREQUENCY/2 #error "GADC: GADC_MAX_HIGH_SPEED_SAMPLERATE has been set too high. It must be less than half the maximum CPU rate" diff --git a/src/gadc/sys_make.mk b/src/gadc/sys_make.mk index 05b1e9cc..21a07dbe 100644 --- a/src/gadc/sys_make.mk +++ b/src/gadc/sys_make.mk @@ -1 +1 @@ -GFXSRC += $(GFXLIB)/src/gadc/gadc.c +GFXSRC += $(GFXLIB)/src/gadc/gadc_gadc.c diff --git a/src/gaudio/gaudio.c b/src/gaudio/gaudio_gaudio.c index ab1f95ee..bb12e6d2 100644 --- a/src/gaudio/gaudio.c +++ b/src/gaudio/gaudio_gaudio.c @@ -6,7 +6,7 @@ */ /** - * @file src/gaudio/gaudio.c + * @file src/gaudio/gaudio_gaudio.c * @brief GAUDIO sub-system code. * * @addtogroup GAUDIO @@ -17,7 +17,7 @@ #if GFX_USE_GAUDIO #if GAUDIO_NEED_PLAY - #include "src/gaudio/driver_play.h" + #include "driver_play.h" static gfxQueueASync playList; static gfxSem playComplete; @@ -32,7 +32,7 @@ #endif #if GAUDIO_NEED_RECORD - #include "src/gaudio/driver_record.h" + #include "driver_record.h" static gfxQueueGSync recordList; static uint16_t recordFlags; diff --git a/src/gaudio/sys_make.mk b/src/gaudio/sys_make.mk index 438892c0..ea02e010 100644 --- a/src/gaudio/sys_make.mk +++ b/src/gaudio/sys_make.mk @@ -1 +1 @@ -GFXSRC += $(GFXLIB)/src/gaudio/gaudio.c +GFXSRC += $(GFXLIB)/src/gaudio/gaudio_gaudio.c diff --git a/src/gdisp/fonts/build_fonts.sh b/src/gdisp/fonts/build_fonts.sh index 4ce93a40..b40f7fb6 100644 --- a/src/gdisp/fonts/build_fonts.sh +++ b/src/gdisp/fonts/build_fonts.sh @@ -72,7 +72,7 @@ for file in *.c; do defname='GDISP_INCLUDE_FONT_'$upper echo '#if defined('$defname') && '$defname >> fonts.h echo '#define GDISP_FONT_FOUND' >> fonts.h - echo '#include "src/gdisp/fonts/'$file'"' >> fonts.h + echo '#include "'$file'"' >> fonts.h echo '#endif' >> fonts.h done diff --git a/src/gdisp/fonts/fonts.h b/src/gdisp/fonts/fonts.h index af851dbd..253d0e2d 100644 --- a/src/gdisp/fonts/fonts.h +++ b/src/gdisp/fonts/fonts.h @@ -3,87 +3,87 @@ #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS10) && GDISP_INCLUDE_FONT_DEJAVUSANS10 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans10.c" +#include "DejaVuSans10.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS12_AA) && GDISP_INCLUDE_FONT_DEJAVUSANS12_AA #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans12_aa.c" +#include "DejaVuSans12_aa.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS12) && GDISP_INCLUDE_FONT_DEJAVUSANS12 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans12.c" +#include "DejaVuSans12.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS16_AA) && GDISP_INCLUDE_FONT_DEJAVUSANS16_AA #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans16_aa.c" +#include "DejaVuSans16_aa.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS16) && GDISP_INCLUDE_FONT_DEJAVUSANS16 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans16.c" +#include "DejaVuSans16.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS24_AA) && GDISP_INCLUDE_FONT_DEJAVUSANS24_AA #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans24_aa.c" +#include "DejaVuSans24_aa.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS24) && GDISP_INCLUDE_FONT_DEJAVUSANS24 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans24.c" +#include "DejaVuSans24.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS32_AA) && GDISP_INCLUDE_FONT_DEJAVUSANS32_AA #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans32_aa.c" +#include "DejaVuSans32_aa.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS32) && GDISP_INCLUDE_FONT_DEJAVUSANS32 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSans32.c" +#include "DejaVuSans32.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA) && GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSansBold12_aa.c" +#include "DejaVuSansBold12_aa.c" #endif #if defined(GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12) && GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/DejaVuSansBold12.c" +#include "DejaVuSansBold12.c" #endif #if defined(GDISP_INCLUDE_FONT_FIXED_10X20) && GDISP_INCLUDE_FONT_FIXED_10X20 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/fixed_10x20.c" +#include "fixed_10x20.c" #endif #if defined(GDISP_INCLUDE_FONT_FIXED_5X8) && GDISP_INCLUDE_FONT_FIXED_5X8 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/fixed_5x8.c" +#include "fixed_5x8.c" #endif #if defined(GDISP_INCLUDE_FONT_FIXED_7X14) && GDISP_INCLUDE_FONT_FIXED_7X14 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/fixed_7x14.c" +#include "fixed_7x14.c" #endif #if defined(GDISP_INCLUDE_FONT_LARGENUMBERS) && GDISP_INCLUDE_FONT_LARGENUMBERS #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/LargeNumbers.c" +#include "LargeNumbers.c" #endif #if defined(GDISP_INCLUDE_FONT_UI1) && GDISP_INCLUDE_FONT_UI1 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/UI1.c" +#include "UI1.c" #endif #if defined(GDISP_INCLUDE_FONT_UI2) && GDISP_INCLUDE_FONT_UI2 #define GDISP_FONT_FOUND -#include "src/gdisp/fonts/UI2.c" +#include "UI2.c" #endif #if defined(GDISP_INCLUDE_USER_FONTS) && GDISP_INCLUDE_USER_FONTS diff --git a/src/gdisp/colors.h b/src/gdisp/gdisp_colors.h index 6e9a7663..b764ccfe 100644 --- a/src/gdisp/colors.h +++ b/src/gdisp/gdisp_colors.h @@ -6,7 +6,7 @@ */ /** - * @file src/gdisp/colors.h + * @file src/gdisp/gdisp_colors.h * @brief GDISP color definitions header file. * * @defgroup Colors Colors diff --git a/src/gdisp/fonts.c b/src/gdisp/gdisp_fonts.c index ea8d1615..cdb8e075 100644 --- a/src/gdisp/fonts.c +++ b/src/gdisp/gdisp_fonts.c @@ -6,7 +6,7 @@ */ /** - * @file src/gdisp/fonts.c + * @file src/gdisp/gdisp_fonts.c * @brief GDISP Font Handling. * * @addtogroup GDISP @@ -17,7 +17,7 @@ #if GFX_USE_GDISP && GDISP_NEED_TEXT -#include "mcufont.h" +#include "mcufont/mcufont.h" /* Custom flag to indicate dynamically allocated font */ #define FONT_FLAG_DYNAMIC 0x80 diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp_gdisp.c index b8b4a847..02ee4711 100644 --- a/src/gdisp/gdisp.c +++ b/src/gdisp/gdisp_gdisp.c @@ -6,7 +6,7 @@ */ /** - * @file src/gdisp/gdisp.c + * @file src/gdisp/gdisp_gdisp.c * @brief GDISP Driver code. * * @addtogroup GDISP @@ -17,7 +17,7 @@ #if GFX_USE_GDISP /* Include the low level driver information */ -#include "src/gdisp/driver.h" +#include "driver.h" #if 1 #undef INLINE @@ -2768,7 +2768,7 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co #endif #if GDISP_NEED_TEXT - #include "mcufont.h" + #include "mcufont/mcufont.h" #if GDISP_NEED_ANTIALIAS && GDISP_HARDWARE_PIXELREAD static void drawcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) { diff --git a/src/gdisp/image.c b/src/gdisp/gdisp_image.c index e2b7d758..2851a7c8 100644 --- a/src/gdisp/image.c +++ b/src/gdisp/gdisp_image.c @@ -6,7 +6,7 @@ */ /** - * @file src/gdisp/image.c + * @file src/gdisp/gdisp_image.c * @brief GDISP generic image code. * * @defgroup Image Image diff --git a/src/gdisp/image.h b/src/gdisp/gdisp_image.h index 76e8bdea..c0941fd5 100644 --- a/src/gdisp/image.h +++ b/src/gdisp/gdisp_image.h @@ -6,7 +6,7 @@ */ /** - * @file src/gdisp/image.h + * @file src/gdisp/gdisp_image.h * @brief GDISP image header file. * * @defgroup Image Image diff --git a/src/gdisp/image_bmp.c b/src/gdisp/gdisp_image_bmp.c index 8ff40ca0..8ff40ca0 100644 --- a/src/gdisp/image_bmp.c +++ b/src/gdisp/gdisp_image_bmp.c diff --git a/src/gdisp/image_gif.c b/src/gdisp/gdisp_image_gif.c index 06f4ef6a..06f4ef6a 100644 --- a/src/gdisp/image_gif.c +++ b/src/gdisp/gdisp_image_gif.c diff --git a/src/gdisp/image_jpg.c b/src/gdisp/gdisp_image_jpg.c index 2f6a9392..2f6a9392 100644 --- a/src/gdisp/image_jpg.c +++ b/src/gdisp/gdisp_image_jpg.c diff --git a/src/gdisp/image_native.c b/src/gdisp/gdisp_image_native.c index 81344642..81344642 100644 --- a/src/gdisp/image_native.c +++ b/src/gdisp/gdisp_image_native.c diff --git a/src/gdisp/image_png.c b/src/gdisp/gdisp_image_png.c index f35174d9..f35174d9 100644 --- a/src/gdisp/image_png.c +++ b/src/gdisp/gdisp_image_png.c diff --git a/src/gdisp/sys_defs.h b/src/gdisp/sys_defs.h index 72fdc621..253de49e 100644 --- a/src/gdisp/sys_defs.h +++ b/src/gdisp/sys_defs.h @@ -185,7 +185,7 @@ extern GDisplay *GDISP; /*===========================================================================*/ /* Load our color definitions and pixel formats */ -#include "colors.h" +#include "gdisp_colors.h" /** * @brief The type of a pixel. @@ -995,7 +995,7 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co #endif #if GDISP_NEED_IMAGE || defined(__DOXYGEN__) - #include "src/gdisp/image.h" + #include "gdisp_image.h" #endif #endif /* GFX_USE_GDISP */ diff --git a/src/gdisp/sys_make.mk b/src/gdisp/sys_make.mk index a133ce37..cbce4224 100644 --- a/src/gdisp/sys_make.mk +++ b/src/gdisp/sys_make.mk @@ -1,11 +1,11 @@ -GFXSRC += $(GFXLIB)/src/gdisp/gdisp.c \ - $(GFXLIB)/src/gdisp/fonts.c \ - $(GFXLIB)/src/gdisp/image.c \ - $(GFXLIB)/src/gdisp/image_native.c \ - $(GFXLIB)/src/gdisp/image_gif.c \ - $(GFXLIB)/src/gdisp/image_bmp.c \ - $(GFXLIB)/src/gdisp/image_jpg.c \ - $(GFXLIB)/src/gdisp/image_png.c +GFXSRC += $(GFXLIB)/src/gdisp/gdisp_gdisp.c \ + $(GFXLIB)/src/gdisp/gdisp_fonts.c \ + $(GFXLIB)/src/gdisp/gdisp_image.c \ + $(GFXLIB)/src/gdisp/gdisp_image_native.c \ + $(GFXLIB)/src/gdisp/gdisp_image_gif.c \ + $(GFXLIB)/src/gdisp/gdisp_image_bmp.c \ + $(GFXLIB)/src/gdisp/gdisp_image_jpg.c \ + $(GFXLIB)/src/gdisp/gdisp_image_png.c MFDIR = $(GFXLIB)/src/gdisp/mcufont include $(GFXLIB)/src/gdisp/mcufont/mcufont.mk diff --git a/src/gevent/gevent.c b/src/gevent/gevent_gevent.c index 0a6ebcc6..fc45102e 100644 --- a/src/gevent/gevent.c +++ b/src/gevent/gevent_gevent.c @@ -6,7 +6,7 @@ */ /** - * @file src/gevent/gevent.c + * @file src/gevent/gevent_gevent.c * @brief GEVENT Driver code. * * @addtogroup GEVENT diff --git a/src/gevent/sys_make.mk b/src/gevent/sys_make.mk index 5744ae46..f8b88e56 100644 --- a/src/gevent/sys_make.mk +++ b/src/gevent/sys_make.mk @@ -1 +1 @@ -GFXSRC += $(GFXLIB)/src/gevent/gevent.c +GFXSRC += $(GFXLIB)/src/gevent/gevent_gevent.c diff --git a/src/gfile/fatfs_chibios_diskio.c b/src/gfile/gfile_fatfs_diskio_chibios.c index 803c96a0..46ddbb7e 100644 --- a/src/gfile/fatfs_chibios_diskio.c +++ b/src/gfile/gfile_fatfs_diskio_chibios.c @@ -5,11 +5,17 @@ /* disk I/O modules and attach it to FatFs module with common interface. */ /*-----------------------------------------------------------------------*/ +/** + * @file src/gfile/gfile_fatfs_diskio_chibios.c + * @brief GFILE FATFS wrapper. + * + */ + #include "gfx.h" #if GFX_USE_GFILE && GFILE_NEED_FATFS && GFX_USE_OS_CHIBIOS -#include "fatfs_wrapper.h" +#include "gfile_fatfs_wrapper.h" #if HAL_USE_MMC_SPI && HAL_USE_SDC #error "cannot specify both MMC_SPI and SDC drivers" diff --git a/src/gfile/fatfs_wrapper.c b/src/gfile/gfile_fatfs_wrapper.c index 3ac8e427..edcab056 100644 --- a/src/gfile/fatfs_wrapper.c +++ b/src/gfile/gfile_fatfs_wrapper.c @@ -6,7 +6,7 @@ */ /** - * @file src/gfile/fatfs_wrapper.c + * @file src/gfile/gfile_fatfs_wrapper.c * @brief GFILE FATFS wrapper. * */ @@ -15,7 +15,7 @@ #if GFX_USE_GFILE && GFILE_NEED_FATFS -#include "fatfs_wrapper.h" +#include "gfile_fatfs_wrapper.h" // Include the source we want #include "3rdparty/fatfs-0.10b/src/ff.c" diff --git a/src/gfile/fatfs_wrapper.h b/src/gfile/gfile_fatfs_wrapper.h index fc08815b..e66e13bc 100644 --- a/src/gfile/fatfs_wrapper.h +++ b/src/gfile/gfile_fatfs_wrapper.h @@ -6,7 +6,7 @@ */ /** - * @file src/gfile/fatfs_wrapper.h + * @file src/gfile/gfile_fatfs_wrapper.h * @brief GFILE FATFS wrapper. * */ diff --git a/src/gfile/inc_chibiosfs.c b/src/gfile/gfile_fs_chibios.c index 72826e28..72826e28 100644 --- a/src/gfile/inc_chibiosfs.c +++ b/src/gfile/gfile_fs_chibios.c diff --git a/src/gfile/inc_fatfs.c b/src/gfile/gfile_fs_fatfs.c index 2e4ef52b..2e4ef52b 100644 --- a/src/gfile/inc_fatfs.c +++ b/src/gfile/gfile_fs_fatfs.c diff --git a/src/gfile/inc_memfs.c b/src/gfile/gfile_fs_mem.c index 150220b8..150220b8 100644 --- a/src/gfile/inc_memfs.c +++ b/src/gfile/gfile_fs_mem.c diff --git a/src/gfile/inc_nativefs.c b/src/gfile/gfile_fs_native.c index b8441ac7..6a9fce94 100644 --- a/src/gfile/inc_nativefs.c +++ b/src/gfile/gfile_fs_native.c @@ -18,7 +18,6 @@ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> -//#include <unistd.h> static bool_t NativeDel(const char *fname); static bool_t NativeExists(const char *fname); diff --git a/src/gfile/inc_petitfs.c b/src/gfile/gfile_fs_petitfs.c index 9b3b510b..9b3b510b 100644 --- a/src/gfile/inc_petitfs.c +++ b/src/gfile/gfile_fs_petitfs.c diff --git a/src/gfile/inc_ramfs.c b/src/gfile/gfile_fs_ram.c index f71eff6c..f71eff6c 100644 --- a/src/gfile/inc_ramfs.c +++ b/src/gfile/gfile_fs_ram.c diff --git a/src/gfile/inc_romfs.c b/src/gfile/gfile_fs_rom.c index 6b7719c7..6b7719c7 100644 --- a/src/gfile/inc_romfs.c +++ b/src/gfile/gfile_fs_rom.c diff --git a/src/gfile/inc_strings.c b/src/gfile/gfile_fs_strings.c index 35c1575c..35c1575c 100644 --- a/src/gfile/inc_strings.c +++ b/src/gfile/gfile_fs_strings.c diff --git a/src/gfile/gfile.c b/src/gfile/gfile_gfile.c index 595bba1f..3547f861 100644 --- a/src/gfile/gfile.c +++ b/src/gfile/gfile_gfile.c @@ -6,7 +6,7 @@ */ /** - * @file src/gfile/gfile.c + * @file src/gfile/gfile_gfile.c * @brief GFILE code. * */ diff --git a/src/gfile/petitfs_chibios_diskio.c b/src/gfile/gfile_petitfs_diskio_chibios.c index dda3f6fc..90e709e4 100644 --- a/src/gfile/petitfs_chibios_diskio.c +++ b/src/gfile/gfile_petitfs_diskio_chibios.c @@ -5,11 +5,17 @@ /* disk I/O modules and attach it to FatFs module with common interface. */ /*-----------------------------------------------------------------------*/ +/** + * @file src/gfile/gfile_petitfs_diskio_chibios.c + * @brief GFILE FATFS wrapper. + * + */ + #include "gfx.h" #if GFX_USE_GFILE && GFILE_NEED_PETITFS && GFX_USE_OS_CHIBIOS -#include "petitfs_wrapper.h" +#include "gfile_petitfs_wrapper.h" #include <string.h> diff --git a/src/gfile/petitfs_wrapper.c b/src/gfile/gfile_petitfs_wrapper.c index 183edb70..8efc7eb9 100644 --- a/src/gfile/petitfs_wrapper.c +++ b/src/gfile/gfile_petitfs_wrapper.c @@ -6,7 +6,7 @@ */ /** - * @file src/gfile/petitfs_wrapper.c + * @file src/gfile/gfile_petitfs_wrapper.c * @brief GFILE PETITFS wrapper. * */ @@ -15,7 +15,7 @@ #if GFX_USE_GFILE && GFILE_NEED_PETITFS -#include "petitfs_wrapper.h" +#include "gfile_petitfs_wrapper.h" // Include the source we want #include "3rdparty/petitfs-0.03/src/pff.c" diff --git a/src/gfile/petitfs_wrapper.h b/src/gfile/gfile_petitfs_wrapper.h index 4f91bd7f..e9080b9e 100644 --- a/src/gfile/petitfs_wrapper.h +++ b/src/gfile/gfile_petitfs_wrapper.h @@ -6,7 +6,7 @@ */ /** - * @file src/gfile/petitfs_wrapper.h + * @file src/gfile/gfile_petitfs_wrapper.h * @brief GFILE PETITFS wrapper. * */ diff --git a/src/gfile/inc_printg.c b/src/gfile/gfile_printg.c index 33db8bc8..33db8bc8 100644 --- a/src/gfile/inc_printg.c +++ b/src/gfile/gfile_printg.c diff --git a/src/gfile/inc_scang.c b/src/gfile/gfile_scang.c index 5fac5ce3..5fac5ce3 100644 --- a/src/gfile/inc_scang.c +++ b/src/gfile/gfile_scang.c diff --git a/src/gfile/inc_stdio.c b/src/gfile/gfile_stdio.c index 20169ef2..20169ef2 100644 --- a/src/gfile/inc_stdio.c +++ b/src/gfile/gfile_stdio.c diff --git a/src/gfile/sys_make.mk b/src/gfile/sys_make.mk index e14527c6..0a85d1ae 100644 --- a/src/gfile/sys_make.mk +++ b/src/gfile/sys_make.mk @@ -1,18 +1,18 @@ -GFXSRC += $(GFXLIB)/src/gfile/gfile.c \ - $(GFXLIB)/src/gfile/inc_nativefs.c \ - $(GFXLIB)/src/gfile/inc_ramfs.c \ - $(GFXLIB)/src/gfile/inc_romfs.c \ - $(GFXLIB)/src/gfile/inc_fatfs.c \ - $(GFXLIB)/src/gfile/inc_petitfs.c \ - $(GFXLIB)/src/gfile/inc_memfs.c \ - $(GFXLIB)/src/gfile/inc_chibiosfs.c \ - $(GFXLIB)/src/gfile/inc_strings.c \ - $(GFXLIB)/src/gfile/inc_printg.c \ - $(GFXLIB)/src/gfile/inc_scang.c \ - $(GFXLIB)/src/gfile/inc_stdio.c \ - $(GFXLIB)/src/gfile/fatfs_wrapper.c \ - $(GFXLIB)/src/gfile/fatfs_chibios_diskio.c \ - $(GFXLIB)/src/gfile/petitfs_wrapper.c \ - $(GFXLIB)/src/gfile/petitfs_chibios_diskio.c \ +GFXSRC += $(GFXLIB)/src/gfile/gfile_gfile.c \ + $(GFXLIB)/src/gfile/gfile_fs_native.c \ + $(GFXLIB)/src/gfile/gfile_fs_ram.c \ + $(GFXLIB)/src/gfile/gfile_fs_rom.c \ + $(GFXLIB)/src/gfile/gfile_fs_fatfs.c \ + $(GFXLIB)/src/gfile/gfile_fs_petitfs.c \ + $(GFXLIB)/src/gfile/gfile_fs_mem.c \ + $(GFXLIB)/src/gfile/gfile_fs_chibios.c \ + $(GFXLIB)/src/gfile/gfile_fs_strings.c \ + $(GFXLIB)/src/gfile/gfile_printg.c \ + $(GFXLIB)/src/gfile/gfile_scang.c \ + $(GFXLIB)/src/gfile/gfile_stdio.c \ + $(GFXLIB)/src/gfile/gfile_fatfs_wrapper.c \ + $(GFXLIB)/src/gfile/gfile_fatfs_diskio_chibios.c \ + $(GFXLIB)/src/gfile/gfile_petitfs_wrapper.c \ + $(GFXLIB)/src/gfile/gfile_petitfs_diskio_chibios.c \
\ No newline at end of file diff --git a/src/ginput/dial.c b/src/ginput/ginput_dial.c index 410efc1a..6af89b31 100644 --- a/src/ginput/dial.c +++ b/src/ginput/ginput_dial.c @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/dial.c + * @file src/ginput/ginput_dial.c * @brief GINPUT dial code. * * @defgroup Dial Dial @@ -17,7 +17,7 @@ #if GFX_USE_GINPUT && GINPUT_NEED_DIAL -#include "src/ginput/driver_dial.h" +#include "driver_dial.h" static GTIMER_DECL(DialTimer); static struct DialStatus_t { diff --git a/src/ginput/dial.h b/src/ginput/ginput_dial.h index f2d3fb58..88a2e165 100644 --- a/src/ginput/dial.h +++ b/src/ginput/ginput_dial.h @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/dial.h + * @file src/ginput/ginput_dial.h * @brief GINPUT GFX User Input subsystem header file. * * @defgroup Dial Dial diff --git a/src/ginput/ginput.c b/src/ginput/ginput_ginput.c index abd16cd8..4197fa25 100644 --- a/src/ginput/ginput.c +++ b/src/ginput/ginput_ginput.c @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/ginput.c + * @file src/ginput/ginput_ginput.c * @brief GINPUT subsystem common code. * * @addtogroup GINPUT diff --git a/src/ginput/keyboard.c b/src/ginput/ginput_keyboard.c index 98fad414..5443572b 100644 --- a/src/ginput/keyboard.c +++ b/src/ginput/ginput_keyboard.c @@ -1,23 +1,23 @@ -/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-/**
- * @file src/ginput/keyboard.c
- * @brief GINPUT keyboard code.
- *
- * @defgroup Keyboard Keyboard
- * @ingroup GINPUT
- *
- * @{
- */
-
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD) || defined(__DOXYGEN__)
- #error "GINPUT: GINPUT_NEED_KEYBOARD - Not Implemented Yet"
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD */
-/** @} */
+/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file src/ginput/ginput_keyboard.c + * @brief GINPUT keyboard code. + * + * @defgroup Keyboard Keyboard + * @ingroup GINPUT + * + * @{ + */ + +#include "gfx.h" + +#if (GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD) || defined(__DOXYGEN__) + #error "GINPUT: GINPUT_NEED_KEYBOARD - Not Implemented Yet" +#endif /* GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD */ +/** @} */ diff --git a/src/ginput/keyboard.h b/src/ginput/ginput_keyboard.h index eff5cc6f..f5737255 100644 --- a/src/ginput/keyboard.h +++ b/src/ginput/ginput_keyboard.h @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/keyboard.h + * @file src/ginput/ginput_keyboard.h * @brief GINPUT GFX User Input subsystem header file. * * @defgroup Keyboard Keyboard diff --git a/src/ginput/mouse.c b/src/ginput/ginput_mouse.c index 1f1a18fe..772e300b 100644 --- a/src/ginput/mouse.c +++ b/src/ginput/ginput_mouse.c @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/mouse.c + * @file src/ginput/ginput_mouse.c * @brief GINPUT mouse/touch code. * * @defgroup Mouse Mouse @@ -17,7 +17,7 @@ #if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) || defined(__DOXYGEN__) -#include "src/ginput/driver_mouse.h" +#include "driver_mouse.h" #if !GINPUT_TOUCH_NOCALIBRATE #if !defined(GFX_USE_GDISP) || !GFX_USE_GDISP diff --git a/src/ginput/mouse.h b/src/ginput/ginput_mouse.h index 79ad1f08..61ad35e0 100644 --- a/src/ginput/mouse.h +++ b/src/ginput/ginput_mouse.h @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/mouse.h + * @file src/ginput/ginput_mouse.h * @brief GINPUT GFX User Input subsystem header file for mouse and touch. * * @defgroup Mouse Mouse diff --git a/src/ginput/toggle.c b/src/ginput/ginput_toggle.c index aad9c862..4c6dc9ae 100644 --- a/src/ginput/toggle.c +++ b/src/ginput/ginput_toggle.c @@ -1,156 +1,156 @@ -/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-/**
- * @file src/ginput/toggle.c
- * @brief GINPUT toggle code.
- *
- * @defgroup Toggle Toggle
- * @ingroup GINPUT
- * @{
- */
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) || defined(__DOXYGEN__)
-
-#include "src/ginput/driver_toggle.h"
-
-#define GINPUT_TOGGLE_ISON 0x01
-#define GINPUT_TOGGLE_INVERT 0x02
-
-static GTIMER_DECL(ToggleTimer);
-static struct GEventToggleStatus_t {
- uint8_t status;
-} ToggleStatus[GINPUT_TOGGLE_NUM_PORTS];
-
-// Our polling function
-static void TogglePoll(void *param) {
- (void) param;
-
- const GToggleConfig *ptc;
- GSourceListener *psl;
- GEventToggle *pe;
- unsigned i, bits, mask;
- uint8_t state;
-
- // Loop while there are bits to get
- for(ptc = GInputToggleConfigTable, i=0; i < GINPUT_TOGGLE_NUM_PORTS; ptc++) {
-
- // Get the next block of bits
- bits = ginput_lld_toggle_getbits(ptc) ^ ptc->invert;
-
- // Extract the bits of use
- for(mask = ptc->mask; i < GINPUT_TOGGLE_NUM_PORTS && mask; mask >>= 1, bits >>= 1) {
- // Ignore bits not in our mask
- if (!(mask & 1))
- continue;
-
- // Calculate our new state
- state = ToggleStatus[i].status & ~GINPUT_TOGGLE_ISON;
- if (state & GINPUT_TOGGLE_INVERT)
- bits ^= 1;
- if (bits & 1)
- state |= GINPUT_TOGGLE_ISON;
-
- // Has it changed?
- if ((state ^ ToggleStatus[i].status) & GINPUT_TOGGLE_ISON) {
-
- // Save the new state
- ToggleStatus[i].status = state;
-
- // Send the event to the listeners that are interested.
- psl = 0;
- while ((psl = geventGetSourceListener((GSourceHandle)(ToggleStatus+i), psl))) {
- if (!(pe = (GEventToggle *)geventGetEventBuffer(psl)))
- continue;
- if ((state & GINPUT_TOGGLE_ISON)) {
- if ((psl->listenflags & GLISTEN_TOGGLE_ON)) {
- pe->type = GEVENT_TOGGLE;
- pe->instance = i;
- pe->on = TRUE;
- geventSendEvent(psl);
- }
- } else {
- if ((psl->listenflags & GLISTEN_TOGGLE_OFF)) {
- pe->type = GEVENT_TOGGLE;
- pe->instance = i;
- pe->on = FALSE;
- geventSendEvent(psl);
- }
- }
- }
- }
-
- // Next toggle switch
- i++;
- }
- }
-}
-
-/* Hardware Toggle/Switch/Button Functions */
-GSourceHandle ginputGetToggle(uint16_t instance) {
- const GToggleConfig *ptc;
-
- if (instance >= GINPUT_TOGGLE_NUM_PORTS)
- return 0;
-
- // Do we need to initialise the toggle subsystem?
- if (!gtimerIsActive(&ToggleTimer)) {
- for(ptc = GInputToggleConfigTable; ptc < GInputToggleConfigTable+sizeof(GInputToggleConfigTable)/sizeof(GInputToggleConfigTable[0]); ptc++)
- ginput_lld_toggle_init(ptc);
- gtimerStart(&ToggleTimer, TogglePoll, 0, TRUE, GINPUT_TOGGLE_POLL_PERIOD);
- }
-
- // OK - return this input
- return (GSourceHandle)(ToggleStatus+instance);
-}
-
-// If invert is true, invert the on/off sense for the toggle
-void ginputInvertToggle(uint16_t instance, bool_t invert) {
- if (instance >= GINPUT_TOGGLE_NUM_PORTS)
- return;
- if (invert) {
- if (!(ToggleStatus[instance].status & GINPUT_TOGGLE_INVERT)) {
- ToggleStatus[instance].status |= GINPUT_TOGGLE_INVERT;
- ToggleStatus[instance].status ^= GINPUT_TOGGLE_ISON;
- }
- } else {
- if ((ToggleStatus[instance].status & GINPUT_TOGGLE_INVERT)) {
- ToggleStatus[instance].status &= ~GINPUT_TOGGLE_INVERT;
- ToggleStatus[instance].status ^= GINPUT_TOGGLE_ISON;
- }
- }
-}
-
-/* Get the current toggle status.
- * Returns FALSE on error (eg invalid instance)
- */
-bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle) {
- // Win32 threads don't seem to recognise priority and/or pre-emption
- // so we add a sleep here to prevent 100% polled applications from locking up.
- gfxSleepMilliseconds(1);
-
- if (instance >= GINPUT_TOGGLE_NUM_PORTS)
- return FALSE;
- ptoggle->type = GEVENT_TOGGLE;
- ptoggle->instance = instance;
- ptoggle->on = (ToggleStatus[instance].status & GINPUT_TOGGLE_ISON) ? TRUE : FALSE;
- return TRUE;
-}
-
-/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */
-void ginputToggleWakeup(void) {
- gtimerJab(&ToggleTimer);
-}
-
-/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */
-void ginputToggleWakeupI(void) {
- gtimerJabI(&ToggleTimer);
-}
-
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
-/** @} */
+/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file src/ginput/ginput_toggle.c + * @brief GINPUT toggle code. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * @{ + */ +#include "gfx.h" + +#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) || defined(__DOXYGEN__) + +#include "driver_toggle.h" + +#define GINPUT_TOGGLE_ISON 0x01 +#define GINPUT_TOGGLE_INVERT 0x02 + +static GTIMER_DECL(ToggleTimer); +static struct GEventToggleStatus_t { + uint8_t status; +} ToggleStatus[GINPUT_TOGGLE_NUM_PORTS]; + +// Our polling function +static void TogglePoll(void *param) { + (void) param; + + const GToggleConfig *ptc; + GSourceListener *psl; + GEventToggle *pe; + unsigned i, bits, mask; + uint8_t state; + + // Loop while there are bits to get + for(ptc = GInputToggleConfigTable, i=0; i < GINPUT_TOGGLE_NUM_PORTS; ptc++) { + + // Get the next block of bits + bits = ginput_lld_toggle_getbits(ptc) ^ ptc->invert; + + // Extract the bits of use + for(mask = ptc->mask; i < GINPUT_TOGGLE_NUM_PORTS && mask; mask >>= 1, bits >>= 1) { + // Ignore bits not in our mask + if (!(mask & 1)) + continue; + + // Calculate our new state + state = ToggleStatus[i].status & ~GINPUT_TOGGLE_ISON; + if (state & GINPUT_TOGGLE_INVERT) + bits ^= 1; + if (bits & 1) + state |= GINPUT_TOGGLE_ISON; + + // Has it changed? + if ((state ^ ToggleStatus[i].status) & GINPUT_TOGGLE_ISON) { + + // Save the new state + ToggleStatus[i].status = state; + + // Send the event to the listeners that are interested. + psl = 0; + while ((psl = geventGetSourceListener((GSourceHandle)(ToggleStatus+i), psl))) { + if (!(pe = (GEventToggle *)geventGetEventBuffer(psl))) + continue; + if ((state & GINPUT_TOGGLE_ISON)) { + if ((psl->listenflags & GLISTEN_TOGGLE_ON)) { + pe->type = GEVENT_TOGGLE; + pe->instance = i; + pe->on = TRUE; + geventSendEvent(psl); + } + } else { + if ((psl->listenflags & GLISTEN_TOGGLE_OFF)) { + pe->type = GEVENT_TOGGLE; + pe->instance = i; + pe->on = FALSE; + geventSendEvent(psl); + } + } + } + } + + // Next toggle switch + i++; + } + } +} + +/* Hardware Toggle/Switch/Button Functions */ +GSourceHandle ginputGetToggle(uint16_t instance) { + const GToggleConfig *ptc; + + if (instance >= GINPUT_TOGGLE_NUM_PORTS) + return 0; + + // Do we need to initialise the toggle subsystem? + if (!gtimerIsActive(&ToggleTimer)) { + for(ptc = GInputToggleConfigTable; ptc < GInputToggleConfigTable+sizeof(GInputToggleConfigTable)/sizeof(GInputToggleConfigTable[0]); ptc++) + ginput_lld_toggle_init(ptc); + gtimerStart(&ToggleTimer, TogglePoll, 0, TRUE, GINPUT_TOGGLE_POLL_PERIOD); + } + + // OK - return this input + return (GSourceHandle)(ToggleStatus+instance); +} + +// If invert is true, invert the on/off sense for the toggle +void ginputInvertToggle(uint16_t instance, bool_t invert) { + if (instance >= GINPUT_TOGGLE_NUM_PORTS) + return; + if (invert) { + if (!(ToggleStatus[instance].status & GINPUT_TOGGLE_INVERT)) { + ToggleStatus[instance].status |= GINPUT_TOGGLE_INVERT; + ToggleStatus[instance].status ^= GINPUT_TOGGLE_ISON; + } + } else { + if ((ToggleStatus[instance].status & GINPUT_TOGGLE_INVERT)) { + ToggleStatus[instance].status &= ~GINPUT_TOGGLE_INVERT; + ToggleStatus[instance].status ^= GINPUT_TOGGLE_ISON; + } + } +} + +/* Get the current toggle status. + * Returns FALSE on error (eg invalid instance) + */ +bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle) { + // Win32 threads don't seem to recognise priority and/or pre-emption + // so we add a sleep here to prevent 100% polled applications from locking up. + gfxSleepMilliseconds(1); + + if (instance >= GINPUT_TOGGLE_NUM_PORTS) + return FALSE; + ptoggle->type = GEVENT_TOGGLE; + ptoggle->instance = instance; + ptoggle->on = (ToggleStatus[instance].status & GINPUT_TOGGLE_ISON) ? TRUE : FALSE; + return TRUE; +} + +/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */ +void ginputToggleWakeup(void) { + gtimerJab(&ToggleTimer); +} + +/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */ +void ginputToggleWakeupI(void) { + gtimerJabI(&ToggleTimer); +} + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */ +/** @} */ diff --git a/src/ginput/toggle.h b/src/ginput/ginput_toggle.h index 40149754..7fc075d6 100644 --- a/src/ginput/toggle.h +++ b/src/ginput/ginput_toggle.h @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/toggle.h + * @file src/ginput/ginput_toggle.h * @brief GINPUT GFX User Input subsystem header file. * * @defgroup Toggle Toggle diff --git a/src/ginput/sys_defs.h b/src/ginput/sys_defs.h index 33259da4..cab1e15d 100644 --- a/src/ginput/sys_defs.h +++ b/src/ginput/sys_defs.h @@ -39,10 +39,10 @@ */ // Include various ginput types -#include "src/ginput/mouse.h" -#include "src/ginput/keyboard.h" -#include "src/ginput/toggle.h" -#include "src/ginput/dial.h" +#include "ginput_mouse.h" +#include "ginput_keyboard.h" +#include "ginput_toggle.h" +#include "ginput_dial.h" #endif /* GFX_USE_GINPUT */ diff --git a/src/ginput/sys_make.mk b/src/ginput/sys_make.mk index 34ac4a55..9abe1645 100644 --- a/src/ginput/sys_make.mk +++ b/src/ginput/sys_make.mk @@ -1,5 +1,5 @@ -GFXSRC += $(GFXLIB)/src/ginput/ginput.c \ - $(GFXLIB)/src/ginput/mouse.c \ - $(GFXLIB)/src/ginput/keyboard.c \ - $(GFXLIB)/src/ginput/toggle.c \ - $(GFXLIB)/src/ginput/dial.c +GFXSRC += $(GFXLIB)/src/ginput/ginput_ginput.c \ + $(GFXLIB)/src/ginput/ginput_mouse.c \ + $(GFXLIB)/src/ginput/ginput_keyboard.c \ + $(GFXLIB)/src/ginput/ginput_toggle.c \ + $(GFXLIB)/src/ginput/ginput_dial.c diff --git a/src/gmisc/arrayops.c b/src/gmisc/gmisc_arrayops.c index 1c4f821a..6e5442cd 100644 --- a/src/gmisc/arrayops.c +++ b/src/gmisc/gmisc_arrayops.c @@ -1,226 +1,226 @@ -/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-/**
- * @file src/gmisc/arrayops.c
- * @brief GMISC Array Operations code.
- *
- * @addtogroup GMISC
- * @{
- */
-#include "gfx.h"
-
-#if GFX_USE_GMISC && GMISC_NEED_ARRAYOPS
-
-void gmiscArrayConvert(ArrayDataFormat srcfmt, void *src, ArrayDataFormat dstfmt, void *dst, size_t cnt) {
- uint8_t *src8, *dst8;
- uint16_t *src16, *dst16;
-
- dst8 = dst;
- dst16 = dst;
- src8 = src;
- src16 = src;
-
- /* We do this as a big switch in order to optimise efficiency for each transfer type */
- switch(dstfmt) {
- case ARRAY_DATA_4BITUNSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8); } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = *src8++ >> 4; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128) >> 4; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 6; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 8; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 10; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 10; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 12; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 12; } break;
- }
- break;
- case ARRAY_DATA_4BITSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8); } break;
- case ARRAY_DATA_4BITSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128) >> 4; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = *src8++ >> 4; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 6; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 8; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 10; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 10; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 12; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 12; } break;
- }
- break;
- case ARRAY_DATA_8BITUNSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = *src8++ << 4; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8) << 4; } break;
- case ARRAY_DATA_8BITUNSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128); } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 2; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 2; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 4; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 4; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 6; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 8; } break;
- }
- break;
- case ARRAY_DATA_8BITSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8) << 4; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = *src8++ << 4; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128); } break;
- case ARRAY_DATA_8BITSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 2; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 2; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 4; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 4; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 6; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 8; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break;
- }
- break;
- case ARRAY_DATA_10BITUNSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 6; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 2; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 2; } break;
- case ARRAY_DATA_10BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512); } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 4; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 6; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 6; } break;
- }
- break;
- case ARRAY_DATA_10BITSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 6; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 2; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 2; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512); } break;
- case ARRAY_DATA_10BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 4; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 6; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 6; } break;
- }
- break;
- case ARRAY_DATA_12BITUNSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 8; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 4; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 4; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 2; } break;
- case ARRAY_DATA_12BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048); } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 4; } break;
- }
- break;
- case ARRAY_DATA_12BITSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 8; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 4; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 4; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 2; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048); } break;
- case ARRAY_DATA_12BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 4; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break;
- }
- break;
- case ARRAY_DATA_14BITUNSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 10; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 10; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 6; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 4; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break;
- case ARRAY_DATA_14BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192); } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 2; } break;
- }
- break;
- case ARRAY_DATA_14BITSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 10; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 10; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 6; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 4; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) << 2; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192); } break;
- case ARRAY_DATA_14BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 2; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
- }
- break;
- case ARRAY_DATA_16BITUNSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 12; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 12; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 8; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 6; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 6; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 4; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break;
- case ARRAY_DATA_16BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
- case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768); } break;
- }
- break;
- case ARRAY_DATA_16BITSIGNED:
- switch(srcfmt) {
- case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 12; } break;
- case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 12; } break;
- case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 8; } break;
- case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break;
- case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 6; } break;
- case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 6; } break;
- case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) << 4; } break;
- case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break;
- case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) << 2; } break;
- case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
- case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768); } break;
- case ARRAY_DATA_16BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
- }
- break;
- }
-}
-
-#endif /* GFX_USE_GMISC && GMISC_NEED_ARRAYOPS */
-/** @} */
+/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file src/gmisc/gmisc_arrayops.c + * @brief GMISC Array Operations code. + * + * @addtogroup GMISC + * @{ + */ +#include "gfx.h" + +#if GFX_USE_GMISC && GMISC_NEED_ARRAYOPS + +void gmiscArrayConvert(ArrayDataFormat srcfmt, void *src, ArrayDataFormat dstfmt, void *dst, size_t cnt) { + uint8_t *src8, *dst8; + uint16_t *src16, *dst16; + + dst8 = dst; + dst16 = dst; + src8 = src; + src16 = src; + + /* We do this as a big switch in order to optimise efficiency for each transfer type */ + switch(dstfmt) { + case ARRAY_DATA_4BITUNSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8); } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = *src8++ >> 4; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128) >> 4; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 6; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 8; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 10; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 10; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 12; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 12; } break; + } + break; + case ARRAY_DATA_4BITSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8); } break; + case ARRAY_DATA_4BITSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128) >> 4; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = *src8++ >> 4; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 6; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 8; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 10; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 10; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 12; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 12; } break; + } + break; + case ARRAY_DATA_8BITUNSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = *src8++ << 4; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8) << 4; } break; + case ARRAY_DATA_8BITUNSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128); } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 2; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 2; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 4; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 4; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 6; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 8; } break; + } + break; + case ARRAY_DATA_8BITSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8) << 4; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = *src8++ << 4; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128); } break; + case ARRAY_DATA_8BITSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 2; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 2; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 4; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 4; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 6; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 8; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break; + } + break; + case ARRAY_DATA_10BITUNSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 6; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 2; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 2; } break; + case ARRAY_DATA_10BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512); } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 4; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 6; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 6; } break; + } + break; + case ARRAY_DATA_10BITSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 6; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 2; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 2; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512); } break; + case ARRAY_DATA_10BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 4; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 6; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 6; } break; + } + break; + case ARRAY_DATA_12BITUNSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 8; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 4; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 4; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 2; } break; + case ARRAY_DATA_12BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048); } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 4; } break; + } + break; + case ARRAY_DATA_12BITSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 8; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 4; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 4; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 2; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048); } break; + case ARRAY_DATA_12BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 4; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break; + } + break; + case ARRAY_DATA_14BITUNSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 10; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 10; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 6; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 4; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break; + case ARRAY_DATA_14BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192); } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 2; } break; + } + break; + case ARRAY_DATA_14BITSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 10; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 10; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 6; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 4; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) << 2; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192); } break; + case ARRAY_DATA_14BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 2; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break; + } + break; + case ARRAY_DATA_16BITUNSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 12; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 12; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 8; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 6; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 6; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 4; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break; + case ARRAY_DATA_16BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break; + case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768); } break; + } + break; + case ARRAY_DATA_16BITSIGNED: + switch(srcfmt) { + case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 12; } break; + case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 12; } break; + case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 8; } break; + case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break; + case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 6; } break; + case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 6; } break; + case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) << 4; } break; + case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break; + case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) << 2; } break; + case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break; + case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768); } break; + case ARRAY_DATA_16BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break; + } + break; + } +} + +#endif /* GFX_USE_GMISC && GMISC_NEED_ARRAYOPS */ +/** @} */ diff --git a/src/gmisc/gmisc.c b/src/gmisc/gmisc_gmisc.c index 654dd5e2..3121182f 100644 --- a/src/gmisc/gmisc.c +++ b/src/gmisc/gmisc_gmisc.c @@ -6,7 +6,7 @@ */ /** - * @file src/gmisc/gmisc.c + * @file src/gmisc/gmisc_gmisc.c * @brief GMISC Functions. * */ diff --git a/src/gmisc/trig.c b/src/gmisc/gmisc_trig.c index 3c6dd461..7314f389 100644 --- a/src/gmisc/trig.c +++ b/src/gmisc/gmisc_trig.c @@ -6,7 +6,7 @@ */ /** - * @file src/gmisc/trig.c + * @file src/gmisc/gmisc_trig.c * @brief GMISC Trig Functions. * * @addtogroup GMISC diff --git a/src/gmisc/sys_make.mk b/src/gmisc/sys_make.mk index 66d19ab0..0431c134 100644 --- a/src/gmisc/sys_make.mk +++ b/src/gmisc/sys_make.mk @@ -1,3 +1,3 @@ -GFXSRC += $(GFXLIB)/src/gmisc/gmisc.c \ - $(GFXLIB)/src/gmisc/arrayops.c \ - $(GFXLIB)/src/gmisc/trig.c +GFXSRC += $(GFXLIB)/src/gmisc/gmisc_gmisc.c \ + $(GFXLIB)/src/gmisc/gmisc_arrayops.c \ + $(GFXLIB)/src/gmisc/gmisc_trig.c diff --git a/src/gqueue/gqueue.c b/src/gqueue/gqueue_gqueue.c index 45ca6fce..5a50c64b 100644 --- a/src/gqueue/gqueue.c +++ b/src/gqueue/gqueue_gqueue.c @@ -6,7 +6,7 @@ */ /** - * @file src/gqueue/gqueue.c + * @file src/gqueue/gqueue_gqueue.c * @brief GQUEUE source file. */ diff --git a/src/gqueue/sys_make.mk b/src/gqueue/sys_make.mk index ab8a0423..f8a542c3 100644 --- a/src/gqueue/sys_make.mk +++ b/src/gqueue/sys_make.mk @@ -1 +1 @@ -GFXSRC += $(GFXLIB)/src/gqueue/gqueue.c +GFXSRC += $(GFXLIB)/src/gqueue/gqueue_gqueue.c diff --git a/src/gtimer/gtimer.c b/src/gtimer/gtimer_gtimer.c index 3e0b6966..5289b7b8 100644 --- a/src/gtimer/gtimer.c +++ b/src/gtimer/gtimer_gtimer.c @@ -1,238 +1,238 @@ -/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-/**
- * @file src/gtimer/gtimer.c
- * @brief GTIMER sub-system code.
- *
- * @addtogroup GTIMER
- * @{
- */
-#include "gfx.h"
-
-#if GFX_USE_GTIMER || defined(__DOXYGEN__)
-
-#define GTIMER_FLG_PERIODIC 0x0001
-#define GTIMER_FLG_INFINITE 0x0002
-#define GTIMER_FLG_JABBED 0x0004
-#define GTIMER_FLG_SCHEDULED 0x0008
-
-/* Don't rework this macro to use a ternary operator - the gcc compiler stuffs it up */
-#define TimeIsWithin(x, start, end) ((end >= start && x >= start && x <= end) || (end < start && (x >= start || x <= end)))
-
-/* This mutex protects access to our tables */
-static gfxMutex mutex;
-static gfxThreadHandle hThread = 0;
-static GTimer *pTimerHead = 0;
-static gfxSem waitsem;
-static DECLARE_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
-
-/*===========================================================================*/
-/* Driver local functions. */
-/*===========================================================================*/
-
-static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
- (void)arg;
- GTimer *pt;
- systemticks_t tm;
- systemticks_t nxtTimeout;
- systemticks_t lastTime;
- GTimerFunction fn;
- void *param;
-
- nxtTimeout = TIME_INFINITE;
- lastTime = 0;
- while(1) {
- /* Wait for work to do. */
- gfxYield(); // Give someone else a go no matter how busy we are
- gfxSemWait(&waitsem, nxtTimeout);
-
- restartTimerChecks:
-
- // Our reference time
- tm = gfxSystemTicks();
- nxtTimeout = TIME_INFINITE;
-
- /* We need to obtain the mutex */
- gfxMutexEnter(&mutex);
-
- if (pTimerHead) {
- pt = pTimerHead;
- do {
- // Do we have something to do for this timer?
- if ((pt->flags & GTIMER_FLG_JABBED) || (!(pt->flags & GTIMER_FLG_INFINITE) && TimeIsWithin(pt->when, lastTime, tm))) {
-
- // Is this timer periodic?
- if ((pt->flags & GTIMER_FLG_PERIODIC) && pt->period != TIME_IMMEDIATE) {
- // Yes - Update ready for the next period
- if (!(pt->flags & GTIMER_FLG_INFINITE)) {
- // We may have skipped a period.
- // We use this complicated formulae rather than a loop
- // because the gcc compiler stuffs up the loop so that it
- // either loops forever or doesn't get executed at all.
- pt->when += ((tm + pt->period - pt->when) / pt->period) * pt->period;
- }
-
- // We are definitely no longer jabbed
- pt->flags &= ~GTIMER_FLG_JABBED;
-
- } else {
- // No - get us off the timers list
- if (pt->next == pt->prev)
- pTimerHead = 0;
- else {
- pt->next->prev = pt->prev;
- pt->prev->next = pt->next;
- if (pTimerHead == pt)
- pTimerHead = pt->next;
- }
- pt->flags = 0;
- }
-
- // Call the callback function
- fn = pt->fn;
- param = pt->param;
- gfxMutexExit(&mutex);
- fn(param);
-
- // We no longer hold the mutex, the callback function may have taken a while
- // and our list may have been altered so start again!
- goto restartTimerChecks;
- }
-
- // Find when we next need to wake up
- if (!(pt->flags & GTIMER_FLG_INFINITE) && pt->when - tm < nxtTimeout)
- nxtTimeout = pt->when - tm;
- pt = pt->next;
- } while(pt != pTimerHead);
- }
-
- // Ready for the next loop
- lastTime = tm;
- gfxMutexExit(&mutex);
- }
- return 0;
-}
-
-void _gtimerInit(void)
-{
- gfxSemInit(&waitsem, 0, 1);
- gfxMutexInit(&mutex);
-}
-
-void _gtimerDeinit(void)
-{
- gfxSemDestroy(&waitsem);
- gfxMutexDestroy(&mutex);
- // Need to destroy GTimer thread here
-}
-
-void gtimerInit(GTimer* pt)
-{
- pt->flags = 0;
-}
-
-void gtimerDeinit(GTimer* pt)
-{
- gtimerStop(pt);
-}
-
-void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, delaytime_t millisec) {
- gfxMutexEnter(&mutex);
-
- // Start our thread if not already going
- if (!hThread) {
- hThread = gfxThreadCreate(waTimerThread, sizeof(waTimerThread), GTIMER_THREAD_PRIORITY, GTimerThreadHandler, 0);
- if (hThread) {gfxThreadClose(hThread);} // We never really need the handle again
- }
-
- // Is this already scheduled?
- if (pt->flags & GTIMER_FLG_SCHEDULED) {
- // Cancel it!
- if (pt->next == pt->prev)
- pTimerHead = 0;
- else {
- pt->next->prev = pt->prev;
- pt->prev->next = pt->next;
- if (pTimerHead == pt)
- pTimerHead = pt->next;
- }
- }
-
- // Set up the timer structure
- pt->fn = fn;
- pt->param = param;
- pt->flags = GTIMER_FLG_SCHEDULED;
- if (periodic)
- pt->flags |= GTIMER_FLG_PERIODIC;
- if (millisec == TIME_INFINITE) {
- pt->flags |= GTIMER_FLG_INFINITE;
- pt->period = TIME_INFINITE;
- } else {
- pt->period = gfxMillisecondsToTicks(millisec);
- pt->when = gfxSystemTicks() + pt->period;
- }
-
- // Just pop it on the end of the queue
- if (pTimerHead) {
- pt->next = pTimerHead;
- pt->prev = pTimerHead->prev;
- pt->prev->next = pt;
- pt->next->prev = pt;
- } else
- pt->next = pt->prev = pTimerHead = pt;
-
- // Bump the thread
- if (!(pt->flags & GTIMER_FLG_INFINITE))
- gfxSemSignal(&waitsem);
- gfxMutexExit(&mutex);
-}
-
-void gtimerStop(GTimer *pt) {
- gfxMutexEnter(&mutex);
- if (pt->flags & GTIMER_FLG_SCHEDULED) {
- // Cancel it!
- if (pt->next == pt->prev)
- pTimerHead = 0;
- else {
- pt->next->prev = pt->prev;
- pt->prev->next = pt->next;
- if (pTimerHead == pt)
- pTimerHead = pt->next;
- }
- // Make sure we know the structure is dead!
- pt->flags = 0;
- }
- gfxMutexExit(&mutex);
-}
-
-bool_t gtimerIsActive(GTimer *pt) {
- return (pt->flags & GTIMER_FLG_SCHEDULED) ? TRUE : FALSE;
-}
-
-void gtimerJab(GTimer *pt) {
- gfxMutexEnter(&mutex);
-
- // Jab it!
- pt->flags |= GTIMER_FLG_JABBED;
-
- // Bump the thread
- gfxSemSignal(&waitsem);
- gfxMutexExit(&mutex);
-}
-
-void gtimerJabI(GTimer *pt) {
- // Jab it!
- pt->flags |= GTIMER_FLG_JABBED;
-
- // Bump the thread
- gfxSemSignalI(&waitsem);
-}
-
-#endif /* GFX_USE_GTIMER */
-/** @} */
-
+/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file src/gtimer/gtimer_gtimer.c + * @brief GTIMER sub-system code. + * + * @addtogroup GTIMER + * @{ + */ +#include "gfx.h" + +#if GFX_USE_GTIMER || defined(__DOXYGEN__) + +#define GTIMER_FLG_PERIODIC 0x0001 +#define GTIMER_FLG_INFINITE 0x0002 +#define GTIMER_FLG_JABBED 0x0004 +#define GTIMER_FLG_SCHEDULED 0x0008 + +/* Don't rework this macro to use a ternary operator - the gcc compiler stuffs it up */ +#define TimeIsWithin(x, start, end) ((end >= start && x >= start && x <= end) || (end < start && (x >= start || x <= end))) + +/* This mutex protects access to our tables */ +static gfxMutex mutex; +static gfxThreadHandle hThread = 0; +static GTimer *pTimerHead = 0; +static gfxSem waitsem; +static DECLARE_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE); + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) { + (void)arg; + GTimer *pt; + systemticks_t tm; + systemticks_t nxtTimeout; + systemticks_t lastTime; + GTimerFunction fn; + void *param; + + nxtTimeout = TIME_INFINITE; + lastTime = 0; + while(1) { + /* Wait for work to do. */ + gfxYield(); // Give someone else a go no matter how busy we are + gfxSemWait(&waitsem, nxtTimeout); + + restartTimerChecks: + + // Our reference time + tm = gfxSystemTicks(); + nxtTimeout = TIME_INFINITE; + + /* We need to obtain the mutex */ + gfxMutexEnter(&mutex); + + if (pTimerHead) { + pt = pTimerHead; + do { + // Do we have something to do for this timer? + if ((pt->flags & GTIMER_FLG_JABBED) || (!(pt->flags & GTIMER_FLG_INFINITE) && TimeIsWithin(pt->when, lastTime, tm))) { + + // Is this timer periodic? + if ((pt->flags & GTIMER_FLG_PERIODIC) && pt->period != TIME_IMMEDIATE) { + // Yes - Update ready for the next period + if (!(pt->flags & GTIMER_FLG_INFINITE)) { + // We may have skipped a period. + // We use this complicated formulae rather than a loop + // because the gcc compiler stuffs up the loop so that it + // either loops forever or doesn't get executed at all. + pt->when += ((tm + pt->period - pt->when) / pt->period) * pt->period; + } + + // We are definitely no longer jabbed + pt->flags &= ~GTIMER_FLG_JABBED; + + } else { + // No - get us off the timers list + if (pt->next == pt->prev) + pTimerHead = 0; + else { + pt->next->prev = pt->prev; + pt->prev->next = pt->next; + if (pTimerHead == pt) + pTimerHead = pt->next; + } + pt->flags = 0; + } + + // Call the callback function + fn = pt->fn; + param = pt->param; + gfxMutexExit(&mutex); + fn(param); + + // We no longer hold the mutex, the callback function may have taken a while + // and our list may have been altered so start again! + goto restartTimerChecks; + } + + // Find when we next need to wake up + if (!(pt->flags & GTIMER_FLG_INFINITE) && pt->when - tm < nxtTimeout) + nxtTimeout = pt->when - tm; + pt = pt->next; + } while(pt != pTimerHead); + } + + // Ready for the next loop + lastTime = tm; + gfxMutexExit(&mutex); + } + return 0; +} + +void _gtimerInit(void) +{ + gfxSemInit(&waitsem, 0, 1); + gfxMutexInit(&mutex); +} + +void _gtimerDeinit(void) +{ + gfxSemDestroy(&waitsem); + gfxMutexDestroy(&mutex); + // Need to destroy GTimer thread here +} + +void gtimerInit(GTimer* pt) +{ + pt->flags = 0; +} + +void gtimerDeinit(GTimer* pt) +{ + gtimerStop(pt); +} + +void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, delaytime_t millisec) { + gfxMutexEnter(&mutex); + + // Start our thread if not already going + if (!hThread) { + hThread = gfxThreadCreate(waTimerThread, sizeof(waTimerThread), GTIMER_THREAD_PRIORITY, GTimerThreadHandler, 0); + if (hThread) {gfxThreadClose(hThread);} // We never really need the handle again + } + + // Is this already scheduled? + if (pt->flags & GTIMER_FLG_SCHEDULED) { + // Cancel it! + if (pt->next == pt->prev) + pTimerHead = 0; + else { + pt->next->prev = pt->prev; + pt->prev->next = pt->next; + if (pTimerHead == pt) + pTimerHead = pt->next; + } + } + + // Set up the timer structure + pt->fn = fn; + pt->param = param; + pt->flags = GTIMER_FLG_SCHEDULED; + if (periodic) + pt->flags |= GTIMER_FLG_PERIODIC; + if (millisec == TIME_INFINITE) { + pt->flags |= GTIMER_FLG_INFINITE; + pt->period = TIME_INFINITE; + } else { + pt->period = gfxMillisecondsToTicks(millisec); + pt->when = gfxSystemTicks() + pt->period; + } + + // Just pop it on the end of the queue + if (pTimerHead) { + pt->next = pTimerHead; + pt->prev = pTimerHead->prev; + pt->prev->next = pt; + pt->next->prev = pt; + } else + pt->next = pt->prev = pTimerHead = pt; + + // Bump the thread + if (!(pt->flags & GTIMER_FLG_INFINITE)) + gfxSemSignal(&waitsem); + gfxMutexExit(&mutex); +} + +void gtimerStop(GTimer *pt) { + gfxMutexEnter(&mutex); + if (pt->flags & GTIMER_FLG_SCHEDULED) { + // Cancel it! + if (pt->next == pt->prev) + pTimerHead = 0; + else { + pt->next->prev = pt->prev; + pt->prev->next = pt->next; + if (pTimerHead == pt) + pTimerHead = pt->next; + } + // Make sure we know the structure is dead! + pt->flags = 0; + } + gfxMutexExit(&mutex); +} + +bool_t gtimerIsActive(GTimer *pt) { + return (pt->flags & GTIMER_FLG_SCHEDULED) ? TRUE : FALSE; +} + +void gtimerJab(GTimer *pt) { + gfxMutexEnter(&mutex); + + // Jab it! + pt->flags |= GTIMER_FLG_JABBED; + + // Bump the thread + gfxSemSignal(&waitsem); + gfxMutexExit(&mutex); +} + +void gtimerJabI(GTimer *pt) { + // Jab it! + pt->flags |= GTIMER_FLG_JABBED; + + // Bump the thread + gfxSemSignalI(&waitsem); +} + +#endif /* GFX_USE_GTIMER */ +/** @} */ + diff --git a/src/gtimer/sys_make.mk b/src/gtimer/sys_make.mk index 801c31a6..e48dc9f5 100644 --- a/src/gtimer/sys_make.mk +++ b/src/gtimer/sys_make.mk @@ -1 +1 @@ -GFXSRC += $(GFXLIB)/src/gtimer/gtimer.c +GFXSRC += $(GFXLIB)/src/gtimer/gtimer_gtimer.c diff --git a/src/gwin/button.c b/src/gwin/gwin_button.c index fc1cb976..35627cfb 100644 --- a/src/gwin/button.c +++ b/src/gwin/gwin_button.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/button.c + * @file src/gwin/gwin_button.c * @brief GWIN sub-system button code */ @@ -14,7 +14,7 @@ #if GFX_USE_GWIN && GWIN_NEED_BUTTON -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" // Parameters for various shapes #define RND_CNR_SIZE 5 // Rounded corner size for rounded buttons @@ -26,28 +26,6 @@ // Our pressed state #define GBUTTON_FLG_PRESSED (GWIN_FIRST_CONTROL_FLAG<<0) -// Send the button event -static void SendButtonEvent(GWidgetObject *gw) { - GSourceListener * psl; - GEvent * pe; - #define pbe ((GEventGWinButton *)pe) - - // Trigger a GWIN Button Event - psl = 0; - while ((psl = geventGetSourceListener(GWIDGET_SOURCE, psl))) { - if (!(pe = geventGetEventBuffer(psl))) - continue; - pbe->type = GEVENT_GWIN_BUTTON; - pbe->button = (GHandle)gw; - #if GWIN_WIDGET_TAGS - pbe->tag = gw->tag; - #endif - geventSendEvent(psl); - } - - #undef pbe -} - #if GINPUT_NEED_MOUSE // A mouse down has occurred over the button static void MouseDown(GWidgetObject *gw, coord_t x, coord_t y) { @@ -68,7 +46,7 @@ static void SendButtonEvent(GWidgetObject *gw) { return; #endif - SendButtonEvent(gw); + _gwinSendEvent(&gw->g, GEVENT_GWIN_BUTTON); } #endif @@ -86,7 +64,7 @@ static void SendButtonEvent(GWidgetObject *gw) { gw->g.flags |= GBUTTON_FLG_PRESSED; _gwinUpdate((GHandle)gw); // Trigger the event on button down (different than for mouse/touch) - SendButtonEvent(gw); + _gwinSendEvent(&gw->g, GEVENT_GWIN_BUTTON); } static void ToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) { diff --git a/src/gwin/button.h b/src/gwin/gwin_button.h index 077b50f4..282ed828 100644 --- a/src/gwin/button.h +++ b/src/gwin/gwin_button.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/button.h + * @file src/gwin/gwin_button.h * @brief GWIN Graphic window subsystem header file. * * @defgroup Button Button @@ -24,24 +24,18 @@ #ifndef _GWIN_BUTTON_H #define _GWIN_BUTTON_H -/* This file is included within "gwin/gwidget.h" */ +/* This file is included within "src/gwin/gwin_widget.h" */ /** * @brief The Event Type for a Button Event */ -#define GEVENT_GWIN_BUTTON (GEVENT_GWIN_FIRST+0) +#define GEVENT_GWIN_BUTTON (GEVENT_GWIN_CTRL_FIRST+0) /** * @brief A Button Event * @note There are currently no GEventGWinButton listening flags - use 0 as the flags to @p gwinAttachListener() */ -typedef struct GEventGWinButton { - GEventType type; // The type of this event (GEVENT_GWIN_BUTTON) - GHandle button; // The button that has been depressed (actually triggered on release) - #if GWIN_WIDGET_TAGS - WidgetTag tag; // The button tag - #endif -} GEventGWinButton; +typedef GEventGWin GEventGWinButton; /** * @brief The button widget structure diff --git a/src/gwin/checkbox.c b/src/gwin/gwin_checkbox.c index 7914ee82..dec085c3 100644 --- a/src/gwin/checkbox.c +++ b/src/gwin/gwin_checkbox.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/checkbox.c + * @file src/gwin/gwin_checkbox.c * @brief GWIN sub-system button code */ @@ -14,7 +14,7 @@ #if (GFX_USE_GWIN && GWIN_NEED_CHECKBOX) || defined(__DOXYGEN__) -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" // Our checked state #define GCHECKBOX_FLG_CHECKED (GWIN_FIRST_CONTROL_FLAG<<0) @@ -31,7 +31,7 @@ static void SendCheckboxEvent(GWidgetObject *gw) { if (!(pe = geventGetEventBuffer(psl))) continue; pce->type = GEVENT_GWIN_CHECKBOX; - pce->checkbox = &gw->g; + pce->gwin = &gw->g; pce->isChecked = (gw->g.flags & GCHECKBOX_FLG_CHECKED) ? TRUE : FALSE; #if GWIN_WIDGET_TAGS pce->tag = gw->tag; diff --git a/src/gwin/checkbox.h b/src/gwin/gwin_checkbox.h index ebd35a0b..3a67d487 100644 --- a/src/gwin/checkbox.h +++ b/src/gwin/gwin_checkbox.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/checkbox.h + * @file src/gwin/gwin_checkbox.h * @brief GWIN Graphic window subsystem header file. * * @defgroup Checkbox Checkbox @@ -22,13 +22,13 @@ #ifndef _GWIN_CHECKBOX_H #define _GWIN_CHECKBOX_H -/* This file is included within "gwin/gwidget.h" */ +/* This file is included within "src/gwin/gwin_widget.h" */ /*===========================================================================*/ /* Driver constants. */ /*===========================================================================*/ -#define GEVENT_GWIN_CHECKBOX (GEVENT_GWIN_FIRST+2) +#define GEVENT_GWIN_CHECKBOX (GEVENT_GWIN_CTRL_FIRST+2) /*===========================================================================*/ /* Type definitions */ @@ -36,11 +36,11 @@ typedef struct GEventGWinCheckbox { GEventType type; // The type of this event (GEVENT_GWIN_CHECKBOX) - GHandle checkbox; // The checkbox that has been depressed (actually triggered on release) - bool_t isChecked; // Is the checkbox currently checked or unchecked? + GHandle gwin; // The checkbox that has been depressed (actually triggered on release) #if GWIN_WIDGET_TAGS WidgetTag tag; // The checkbox tag #endif + bool_t isChecked; // Is the checkbox currently checked or unchecked? } GEventGWinCheckbox; /* A Checkbox window */ diff --git a/src/gwin/class_gwin.h b/src/gwin/gwin_class.h index 488f3d68..4dde3624 100644 --- a/src/gwin/class_gwin.h +++ b/src/gwin/gwin_class.h @@ -6,7 +6,7 @@ */ /* - * @file src/gwin/class_gwin.h + * @file src/gwin/gwin_class.h * @brief GWIN Graphic window subsystem header file. * * @defgroup Internal Internal @@ -14,7 +14,7 @@ * * @note These definitions are normally not used by an application program. They are useful * only if you want to create your own custom GWIN window or widget. - * @note To access these definitions you must include "gwin/class_gwin.h" in your source file. + * @note To access these definitions you must include "src/gwin/gwin_class.h" in your source file. * * @{ */ @@ -243,7 +243,7 @@ bool_t _gwinDrawStart(GHandle gh); void _gwinDrawEnd(GHandle gh); /** - * @brief Flush any pending redraws in the system. + * @brief Destroy a window. * * @param[in] gh The window * @param[in] how Do we wait for the lock? @@ -301,6 +301,18 @@ bool_t _gwinWMAdd(GHandle gh, const GWindowInit *pInit); * @notapi */ void _gwidgetRedraw(GHandle gh); + + /** + * @brief Send a standard GWIN event. + * + * @param[in] gh The window + * @param[in] type The event type + * + * @note No consideration is given to recording EVENT LOST statuses. + * + * @notapi + */ + void _gwinSendEvent(GHandle gh, GEventType type); #endif #if GWIN_NEED_CONTAINERS || defined(__DOXYGEN__) diff --git a/src/gwin/console.c b/src/gwin/gwin_console.c index 0380fd61..4c17034d 100644 --- a/src/gwin/console.c +++ b/src/gwin/gwin_console.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/console.c + * @file src/gwin/gwin_console.c * @brief GWIN sub-system console code. */ @@ -16,7 +16,7 @@ #include <string.h> -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" #define GWIN_CONSOLE_USE_CLEAR_LINES TRUE // Clear each line before using it #define GWIN_CONSOLE_USE_FILLED_CHARS FALSE // Use filled characters instead of drawn characters diff --git a/src/gwin/console.h b/src/gwin/gwin_console.h index 2a8f4a0a..77e623eb 100644 --- a/src/gwin/console.h +++ b/src/gwin/gwin_console.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/console.h + * @file src/gwin/gwin_console.h * @brief GWIN Graphic window subsystem header file. * * @defgroup Console Console @@ -24,7 +24,7 @@ #ifndef _GWIN_CONSOLE_H #define _GWIN_CONSOLE_H -/* This file is included within "gwin/gwin.h" */ +/* This file is included within "src/gwin/sys_defs.h" */ // A console window. Supports wrapped text writing and a cursor. typedef struct GConsoleObject { diff --git a/src/gwin/gcontainer.c b/src/gwin/gwin_container.c index 97b5fabb..3145ae56 100644 --- a/src/gwin/gcontainer.c +++ b/src/gwin/gwin_container.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/gcontainer.c + * @file src/gwin/gwin_container.c * @brief GWIN sub-system container code */ @@ -14,7 +14,7 @@ #if GFX_USE_GWIN && GWIN_NEED_CONTAINERS -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" void _gcontainerInit(void) { diff --git a/src/gwin/gcontainer.h b/src/gwin/gwin_container.h index 98707ede..ff1c1ce9 100644 --- a/src/gwin/gcontainer.h +++ b/src/gwin/gwin_container.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/gcontainer.h + * @file src/gwin/gwin_container.h * * @defgroup Container Container * @ingroup Containers @@ -21,7 +21,7 @@ #ifndef _GCONTAINER_H #define _GCONTAINER_H -/* This file is included within "gwin/gwin.h" */ +/* This file is included within "src/gwin/sys_defs.h" */ // Forward definition struct GContainerObject; @@ -154,7 +154,7 @@ extern "C" { /* Include extra container types */ #if GWIN_NEED_FRAME || defined(__DOXYGEN__) - #include "src/gwin/frame.h" + #include "gwin_frame.h" #endif #endif /* _GCONTAINER_H */ diff --git a/src/gwin/frame.c b/src/gwin/gwin_frame.c index ec0bf632..63df3be2 100644 --- a/src/gwin/frame.c +++ b/src/gwin/gwin_frame.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/frame.c + * @file src/gwin/gwin_frame.c * @brief GWIN sub-system frame code. */ @@ -14,7 +14,7 @@ #if GFX_USE_GWIN && GWIN_NEED_FRAME -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" /* Some position values */ #define BUTTON_X 18 // Button Width @@ -95,6 +95,7 @@ static void forceFrameRedraw(GWidgetObject *gw) { // Close is released - destroy the window gw->g.flags &= ~(GWIN_FRAME_CLOSE_PRESSED|GWIN_FRAME_MAX_PRESSED|GWIN_FRAME_MIN_PRESSED); forceFrameRedraw(gw); + _gwinSendEvent(&gw->g, GEVENT_GWIN_CLOSE); gwinDestroy(&gw->g); return; } @@ -304,10 +305,10 @@ void gwinFrameDraw_Std(GWidgetObject *gw, void *param) { // Draw the client area by tiling the image mx = gw->g.x+gw->g.width - BORDER_R; my = gw->g.y+gw->g.height - BORDER_B; - for(y = gw->g.y+BORDER_T, ih=gi->height; y < my; y += ih) { + for(y = gw->g.y+BORDER_T, ih = gi->height; y < my; y += ih) { if (ih > my - y) ih = my - y; - for(x = gw->g.x+BORDER_L; iw=gi->width; x < mx; x += iw) { + for(x = gw->g.x+BORDER_L; iw = gi->width; x < mx; x += iw) { if (iw > mx - x) iw = mx - x; gdispGImageDraw(gw->g.display, gi, x, y, ih, iw, 0, 0); diff --git a/src/gwin/frame.h b/src/gwin/gwin_frame.h index 58e1fbc9..f71a88a5 100644 --- a/src/gwin/frame.h +++ b/src/gwin/gwin_frame.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/frame.h + * @file src/gwin/gwin_frame.h * @brief GWIN Graphic window subsystem header file. * * @defgroup Frame Frame @@ -23,6 +23,8 @@ #ifndef _GWIN_FRAME_H #define _GWIN_FRAME_H +/* This file is included from src/gwin/gwin_container.h */ + /** * @brief Flags for gwinFrameCreate() * @{ diff --git a/src/gwin/gwin_gl3d.c b/src/gwin/gwin_gl3d.c new file mode 100644 index 00000000..6e16479e --- /dev/null +++ b/src/gwin/gwin_gl3d.c @@ -0,0 +1,171 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file src/gwin/gwin_gl3d.c + * @brief GWIN sub-system button code + */ + +#include "gfx.h" + +#if GFX_USE_GWIN && GWIN_NEED_GL3D + +#if GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB565 + #error "GWIN: GL3D only support GDISP_PIXELFORMAT_RGB565 color format (TinyGL limitation)" +#endif + +#include "gwin_class.h" + +#include "3rdparty/tinygl-0.4-ugfx/src/zgl.h" + +// Forward definitions +static void gl3dDestroy(GWindowObject *gh); +static void gl3dRedraw(GWindowObject *gh); +static int gl3dResizeGLViewport(GLContext *c, int *xsize_ptr, int *ysize_ptr); + +static const gwinVMT gl3dVMT = { + "GL3D", // The classname + sizeof(GGL3DObject), // The object size + gl3dDestroy, // The destroy routine + gl3dRedraw, // The redraw routine + 0, // The after-clear routine +}; + +static bool_t haveGLwindow = FALSE; + +GHandle gwinGGL3DCreate(GDisplay *g, GGL3DObject *gl, const GWindowInit *pInit) { + ZBuffer * zb; + GLContext * glcxt; + + // Only one GL3D window allowed at a time (TinyGL limitation) + if (haveGLwindow) + return 0; + + if (!(gl = (GGL3DObject *)_gwindowCreate(g, &gl->g, pInit, &gl3dVMT, 0))) + return 0; + + // Must be a multiple of 4 bytes + gl->g.width &= ~3; + gl->g.height &= ~3; + + zb = ZB_open(gl->g.width, gl->g.height, ZB_MODE_5R6G5B, 0, NULL, NULL, NULL); + if (!zb) { + if ((gl->g.flags & GWIN_FLG_DYNAMIC)) + gfxFree(gl); + return 0; + } + + /* initialisation of the TinyGL interpreter */ + glInit(zb); + gl->glcxt = glcxt = gl_get_context(); + glcxt->opaque = gl; + glcxt->gl_resize_viewport = gl3dResizeGLViewport; + + /* set the viewport : we force a call to the viewport resize routine */ + glcxt->viewport.xsize=-1; + glcxt->viewport.ysize=-1; + + glViewport(0, 0, gl->g.width, gl->g.height); + + haveGLwindow = TRUE; + gwinSetVisible((GHandle)gl, pInit->show); + return (GHandle)gl; +} + +static void gl3dDestroy(GWindowObject *gh) { + (void) gh; + glClose(); + haveGLwindow = FALSE; +} + +static void gl3dRedraw(GWindowObject *gh) { + ZBuffer * zb; + + zb = ((GGL3DObject *)gh)->glcxt->zb; + gdispGBlitArea(gh->display, gh->x, gh->y, zb->xsize, zb->ysize, 0, 0, zb->linesize/sizeof(color_t), (const pixel_t *)zb->pbuf); +} + +static int gl3dResizeGLViewport(GLContext *c, int *xsize_ptr, int *ysize_ptr) { + int cx, cy; + + cx = *xsize_ptr; + cy = *ysize_ptr; + + // We ensure that cx and cy are multiples of 4 for the zbuffer. TODO: find a better solution + cx &= ~3; + cy &= ~3; + + if (cx <= 0 || cy <= 0) + return -1; + + *xsize_ptr = cx; + *ysize_ptr = cy; + + // Resize the GWIN??? + + // Resize the Z buffer + ZB_resize(c->zb, NULL, cx, cy); + return 0; +} + +/** + * TinyGL support routines + */ + +#include <string.h> + +#define NO_CLIBRARY + +void tgl_warning(const char *format, ...) { (void)format; } +void tgl_trace(const char *format, ...) { (void)format; } +void tgl_fixme(const char *format, ...) { (void)format; } +void gl_fatal_error(char *format, ...) { gfxHalt(format); } +void gl_assert(int test) { if (!test) gfxHalt("TinyGL Assert"); } + +void gl_free(void *p) { gfxFree(p); } +void *gl_malloc(int size) { return gfxAlloc(size); } + +void *gl_zalloc(int size) { + void *p; + + p = gfxAlloc(size); + if (p) + memset(p, 0, size); + return p; +} + + +/** + * Pre-load TinyGL headers + */ + +/** + * TinyGL wrapper code + */ + +#include "3rdparty/tinygl-0.4-ugfx/src/api.c" +#include "3rdparty/tinygl-0.4-ugfx/src/list.c" +#include "3rdparty/tinygl-0.4-ugfx/src/vertex.c" +#include "3rdparty/tinygl-0.4-ugfx/src/init.c" +#include "3rdparty/tinygl-0.4-ugfx/src/matrix.c" +#include "3rdparty/tinygl-0.4-ugfx/src/texture.c" +#include "3rdparty/tinygl-0.4-ugfx/src/misc.c" +#include "3rdparty/tinygl-0.4-ugfx/src/clear.c" +#include "3rdparty/tinygl-0.4-ugfx/src/light.c" +#include "3rdparty/tinygl-0.4-ugfx/src/clip.c" +#include "3rdparty/tinygl-0.4-ugfx/src/select.c" +#include "3rdparty/tinygl-0.4-ugfx/src/get.c" +#include "3rdparty/tinygl-0.4-ugfx/src/zbuffer.c" +#include "3rdparty/tinygl-0.4-ugfx/src/zline.c" +#include "3rdparty/tinygl-0.4-ugfx/src/zdither.c" +#include "3rdparty/tinygl-0.4-ugfx/src/ztriangle.c" +#include "3rdparty/tinygl-0.4-ugfx/src/zmath.c" +#include "3rdparty/tinygl-0.4-ugfx/src/image_util.c" +#include "3rdparty/tinygl-0.4-ugfx/src/arrays.c" +#include "3rdparty/tinygl-0.4-ugfx/src/specbuf.c" + +#endif /* GFX_USE_GWIN && GWIN_NEED_GL3D */ diff --git a/src/gwin/gwin_gl3d.h b/src/gwin/gwin_gl3d.h new file mode 100644 index 00000000..644f45bf --- /dev/null +++ b/src/gwin/gwin_gl3d.h @@ -0,0 +1,70 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file src/gwin/gwin_gl3d.h + * @brief GWIN 3D module header file + * + * @defgroup 3D 3D + * @ingroup Windows + * + * @details 3D GWIN window based on OpenGL (or more exactly Tiny GL) + * @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h + * @pre GWIN_NEED_GL3D must be set to TRUE in your gfxconf.h + * + * @{ + */ + +#ifndef _GWIN_GL3D_H +#define _GWIN_GL3D_H + +/* This file is included within "src/gwin/sys_defs.h" */ + + +// A gl3d window +typedef struct GGL3DObject { + GWindowObject g; + struct GLContext * glcxt; + } GGL3DObject; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a gl3d window. + * @return NULL if there is no resultant drawing area, otherwise a window handle. + * + * @param[in] g The GDisplay to display this window on + * @param[in] gg The GGL3DObject structure to initialise. If this is NULL the structure is dynamically allocated. + * @param[in] pInit The initialization parameters to use + * + * @note The drawing color and the background color get set to the current defaults. If you haven't called + * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively. + * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there + * is no default font and text drawing operations will no nothing. + * @note The dimensions and position may be changed to fit on the real screen. + * + * @api + */ +GHandle gwinGGL3DCreate(GDisplay *g, GGL3DObject *gg, const GWindowInit *pInit); +#define gwinGL3DCreate(gg, pInit) gwinGGL3DCreate(GDISP, gg, pInit) + +/* Include the gl interface */ +#include "3rdparty/tinygl-0.4-ugfx/include/GL/gl.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _GWIN_GL3D_H */ +/** @} */ + diff --git a/src/gwin/graph.c b/src/gwin/gwin_graph.c index 4fcfad37..8a450a9f 100644 --- a/src/gwin/graph.c +++ b/src/gwin/gwin_graph.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/graph.c + * @file src/gwin/gwin_graph.c * @brief GWIN sub-system button code */ @@ -14,7 +14,7 @@ #if GFX_USE_GWIN && GWIN_NEED_GRAPH -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" #define GGRAPH_FLG_CONNECTPOINTS (GWIN_FIRST_CONTROL_FLAG<<0) #define GGRAPH_ARROW_SIZE 5 diff --git a/src/gwin/graph.h b/src/gwin/gwin_graph.h index be51f66c..eea80679 100644 --- a/src/gwin/graph.h +++ b/src/gwin/gwin_graph.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/graph.h + * @file src/gwin/gwin_graph.h * @brief GWIN GRAPH module header file * * @defgroup Graph Graph @@ -22,7 +22,7 @@ #ifndef _GWIN_GRAPH_H #define _GWIN_GRAPH_H -/* This file is included within "gwin/gwin.h" */ +/* This file is included within "src/gwin/sys_defs.h" */ typedef enum GGraphPointType_e { GGRAPH_POINT_NONE, GGRAPH_POINT_DOT, GGRAPH_POINT_SQUARE, GGRAPH_POINT_CIRCLE diff --git a/src/gwin/gwin.c b/src/gwin/gwin_gwin.c index 9b0fb03a..a4cef125 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin_gwin.c @@ -5,11 +5,16 @@ * http://ugfx.org/license.html */ +/** + * @file src/gwin/gwin_gwin.c + * @brief GWIN sub-system code + */ + #include "gfx.h" #if GFX_USE_GWIN -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" /*----------------------------------------------- * Data @@ -101,6 +106,40 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit return (GHandle)pgw; } +// Internal routine for use by GWIN components only +void _gwinDestroy(GHandle gh, GRedrawMethod how) { + if (!gh) + return; + + // Make the window invisible + gwinSetVisible(gh, FALSE); + + // Make sure it is flushed first - must be REDRAW_WAIT or REDRAW_INSESSION + _gwinFlushRedraws(how); + + #if GWIN_NEED_CONTAINERS + // Notify the parent it is about to be deleted + if (gh->parent && ((gcontainerVMT *)gh->parent->vmt)->NotifyDelete) + ((gcontainerVMT *)gh->parent->vmt)->NotifyDelete(gh->parent, gh); + #endif + + // Remove from the window manager + #if GWIN_NEED_WINDOWMANAGER + _GWINwm->vmt->Delete(gh); + #endif + + // Class destroy routine + if (gh->vmt->Destroy) + gh->vmt->Destroy(gh); + + // Clean up the structure + if (gh->flags & GWIN_FLG_DYNAMIC) { + gh->flags = 0; // To be sure, to be sure + gfxFree((void *)gh); + } else + gh->flags = 0; // To be sure, to be sure +} + /*----------------------------------------------- * Routines that affect all windows *-----------------------------------------------*/ @@ -152,39 +191,6 @@ GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pI return pgw; } -void _gwinDestroy(GHandle gh, GRedrawMethod how) { - if (!gh) - return; - - // Make the window invisible - gwinSetVisible(gh, FALSE); - - // Make sure it is flushed first - must be REDRAW_WAIT or REDRAW_INSESSION - _gwinFlushRedraws(how); - - #if GWIN_NEED_CONTAINERS - // Notify the parent it is about to be deleted - if (gh->parent && ((gcontainerVMT *)gh->parent->vmt)->NotifyDelete) - ((gcontainerVMT *)gh->parent->vmt)->NotifyDelete(gh->parent, gh); - #endif - - // Remove from the window manager - #if GWIN_NEED_WINDOWMANAGER - _GWINwm->vmt->Delete(gh); - #endif - - // Class destroy routine - if (gh->vmt->Destroy) - gh->vmt->Destroy(gh); - - // Clean up the structure - if (gh->flags & GWIN_FLG_DYNAMIC) { - gh->flags = 0; // To be sure, to be sure - gfxFree((void *)gh); - } else - gh->flags = 0; // To be sure, to be sure -} - void gwinDestroy(GHandle gh) { _gwinDestroy(gh, REDRAW_WAIT); } diff --git a/src/gwin/gimage.c b/src/gwin/gwin_image.c index d5ca2c38..370d7bdd 100644 --- a/src/gwin/gimage.c +++ b/src/gwin/gwin_image.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/gimage.c + * @file src/gwin/gwin_image.c * @brief GWIN sub-system image code */ @@ -14,7 +14,7 @@ #if GFX_USE_GWIN && GWIN_NEED_IMAGE -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" #define widget(gh) ((GImageObject *)gh) diff --git a/src/gwin/gimage.h b/src/gwin/gwin_image.h index 0052f024..2e0a3218 100644 --- a/src/gwin/gimage.h +++ b/src/gwin/gwin_image.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/gimage.h + * @file src/gwin/gwin_image.h * @brief GWIN image widget header file. * * @defgroup ImageBox ImageBox @@ -27,7 +27,7 @@ #ifndef _GWIN_IMAGE_H #define _GWIN_IMAGE_H -// This file is included within "gwin/gwin.h" +// This file is included within "src/gwin/sys_defs.h" // An image window typedef struct GImageObject { diff --git a/src/gwin/label.c b/src/gwin/gwin_label.c index 4faba95c..3be9d0a9 100644 --- a/src/gwin/label.c +++ b/src/gwin/gwin_label.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/label.c + * @file src/gwin/gwin_label.c * @brief GWIN label widget header file */ @@ -14,7 +14,7 @@ #if GFX_USE_GWIN && GWIN_NEED_LABEL -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" // macros to assist in data type conversions #define gh2obj ((GLabelObject *)gh) diff --git a/src/gwin/label.h b/src/gwin/gwin_label.h index e0b32240..b5c45589 100644 --- a/src/gwin/label.h +++ b/src/gwin/gwin_label.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/label.h + * @file src/gwin/gwin_label.h * @brief GWIN label widget header file * * @defgroup Label Label @@ -27,7 +27,7 @@ #ifndef _GWIN_LABEL_H #define _GWIN_LABEL_H -// This file is included within "gwin/gwin.h" +// This file is included within "src/gwin/gwin_widget.h" // An label window typedef struct GLabelObject { diff --git a/src/gwin/list.c b/src/gwin/gwin_list.c index 98ec2ed5..265053e1 100644 --- a/src/gwin/list.c +++ b/src/gwin/gwin_list.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/list.c + * @file src/gwin/gwin_list.c * @brief GWIN list widget header file */ @@ -14,7 +14,7 @@ #if GFX_USE_GWIN && GWIN_NEED_LIST -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" #include <string.h> #include <stdlib.h> @@ -64,7 +64,7 @@ static void sendListEvent(GWidgetObject *gw, int item) { continue; ple->type = GEVENT_GWIN_LIST; - ple->list = (GHandle)gw; + ple->gwin = (GHandle)gw; ple->item = item; #if GWIN_WIDGET_TAGS ple->tag = gw->tag; diff --git a/src/gwin/list.h b/src/gwin/gwin_list.h index 1eae3c19..a55d4cb8 100644 --- a/src/gwin/list.h +++ b/src/gwin/gwin_list.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/list.h + * @file src/gwin/gwin_list.h * @brief GWIN list widget header file * * @defgroup List List @@ -26,23 +26,23 @@ #ifndef _GWIN_LIST_H #define _GWIN_LIST_H -// This file is included within "gwin/gwin.h" +// This file is included within "src/gwin/gwin_widget.h" /** * @brief The event type for a list event */ -#define GEVENT_GWIN_LIST (GEVENT_GWIN_FIRST+4) +#define GEVENT_GWIN_LIST (GEVENT_GWIN_CTRL_FIRST+4) /** * @brief A list event */ typedef struct GEventGWinList { GEventType type; // The type of this event (GEVENT_GWIN_LIST) - GHandle list; // The list - int item; // The item that has been selected (or unselected in a multi-select listbox) + GHandle gwin; // The list #if GWIN_WIDGET_TAGS WidgetTag tag; // The list tag #endif + int item; // The item that has been selected (or unselected in a multi-select listbox) } GEventGWinList; // A list window diff --git a/src/gwin/progressbar.c b/src/gwin/gwin_progressbar.c index 90be6e43..ef28e8dc 100644 --- a/src/gwin/progressbar.c +++ b/src/gwin/gwin_progressbar.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/progressbar.c + * @file src/gwin/gwin_progressbar.c * @brief GWIN sub-system progressbar code */ @@ -14,7 +14,7 @@ #if (GFX_USE_GWIN && GWIN_NEED_PROGRESSBAR) || defined(__DOXYGEN__) -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" // Reset the display position back to the value predicted by the saved progressbar position static void ResetDisplayPos(GProgressbarObject *gsw) { diff --git a/src/gwin/progressbar.h b/src/gwin/gwin_progressbar.h index 4dadf904..49c11a98 100644 --- a/src/gwin/progressbar.h +++ b/src/gwin/gwin_progressbar.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/progressbar.h + * @file src/gwin/gwin_progressbar.h * @brief GWIN Graphic window subsystem header file. * * @defgroup Progressbar Progressbar @@ -22,6 +22,7 @@ #ifndef _GWIN_PROGRESSBAR_H #define _GWIN_PROGRESSBAR_H +/* This file is included within src/gwin/gwin_widget.h */ // A progressbar window typedef struct GProgressbarObject { GWidgetObject w; diff --git a/src/gwin/radio.c b/src/gwin/gwin_radio.c index 557061e4..0bafa7cc 100644 --- a/src/gwin/radio.c +++ b/src/gwin/gwin_radio.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/radio.c + * @file src/gwin/gwin_radio.c * @brief GWIN sub-system radio button code */ @@ -14,7 +14,7 @@ #if GFX_USE_GWIN && GWIN_NEED_RADIO -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" #define GRADIO_TAB_CNR 8 // Diagonal corner on active tab #define GRADIO_TOP_FADE 50 // (GRADIO_TOP_FADE/255)% fade to white for top of tab/button @@ -36,7 +36,7 @@ static void SendRadioEvent(GWidgetObject *gw) { if (!(pe = geventGetEventBuffer(psl))) continue; pbe->type = GEVENT_GWIN_RADIO; - pbe->radio = (GHandle)gw; + pbe->gwin = (GHandle)gw; pbe->group = ((GRadioObject *)gw)->group; #if GWIN_WIDGET_TAGS pbe->tag = gw->tag; diff --git a/src/gwin/radio.h b/src/gwin/gwin_radio.h index eb7ee719..d5c9c21a 100644 --- a/src/gwin/radio.h +++ b/src/gwin/gwin_radio.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/radio.h + * @file src/gwin/gwin_radio.h * @brief GWIN Graphic window subsystem header file. * * @defgroup RadioButton RadioButton @@ -22,12 +22,12 @@ #ifndef _GWIN_RADIO_H #define _GWIN_RADIO_H -/* This file is included within "gwin/gwidget.h" */ +/* This file is included within "src/gwin/gwin_widget.h" */ /** * @brief The Event Type for a Radio Event */ -#define GEVENT_GWIN_RADIO (GEVENT_GWIN_FIRST+3) +#define GEVENT_GWIN_RADIO (GEVENT_GWIN_CTRL_FIRST+3) /** * @brief A Button Event @@ -35,11 +35,11 @@ */ typedef struct GEventGWinRadio { GEventType type; // The type of this event (GEVENT_GWIN_RADIO) - GHandle radio; // The radio button that has been depressed - uint16_t group; // The group for this radio button + GHandle gwin; // The radio button that has been depressed #if GWIN_WIDGET_TAGS WidgetTag tag; // The radio tag #endif + uint16_t group; // The group for this radio button } GEventGWinRadio; /** diff --git a/src/gwin/slider.c b/src/gwin/gwin_slider.c index 7ce7b83f..f1230d5a 100644 --- a/src/gwin/slider.c +++ b/src/gwin/gwin_slider.c @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/slider.c + * @file src/gwin/gwin_slider.c * @brief GWIN sub-system slider code */ @@ -14,7 +14,7 @@ #if (GFX_USE_GWIN && GWIN_NEED_SLIDER) || defined(__DOXYGEN__) -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" #ifndef GWIN_SLIDER_DEAD_BAND #define GWIN_SLIDER_DEAD_BAND 5 @@ -36,7 +36,7 @@ static void SendSliderEvent(GWidgetObject *gw) { if (!(pe = geventGetEventBuffer(psl))) continue; pse->type = GEVENT_GWIN_SLIDER; - pse->slider = (GHandle)gw; + pse->gwin = (GHandle)gw; pse->position = ((GSliderObject *)gw)->pos; #if GWIN_WIDGET_TAGS pse->tag = gw->tag; diff --git a/src/gwin/slider.h b/src/gwin/gwin_slider.h index 32161d62..b88d6dfd 100644 --- a/src/gwin/slider.h +++ b/src/gwin/gwin_slider.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/slider.h + * @file src/gwin/gwin_slider.h * @brief GWIN Graphic window subsystem header file. * * @defgroup Slider Slider @@ -22,17 +22,17 @@ #ifndef _GWIN_SLIDER_H #define _GWIN_SLIDER_H -/* This file is included within "gwin/gwidget.h" */ +/* This file is included within "src/gwin/gwin_widget.h" */ -#define GEVENT_GWIN_SLIDER (GEVENT_GWIN_FIRST+1) +#define GEVENT_GWIN_SLIDER (GEVENT_GWIN_CTRL_FIRST+1) typedef struct GEventGWinSlider { GEventType type; // The type of this event (GEVENT_GWIN_BUTTON) - GHandle slider; // The slider that is returning results - int position; + GHandle gwin; // The slider that is returning results #if GWIN_WIDGET_TAGS WidgetTag tag; // The slider tag #endif + int position; } GEventGWinSlider; // There are currently no GEventGWinSlider listening flags - use 0 diff --git a/src/gwin/gwidget.c b/src/gwin/gwin_widget.c index c9fff50e..f85e6f20 100644 --- a/src/gwin/gwidget.c +++ b/src/gwin/gwin_widget.c @@ -5,13 +5,18 @@ * http://ugfx.org/license.html */ +/** + * @file src/gwin/gwin_widget.c + * @brief GWIN sub-system widget code + */ + #include "gfx.h" #if GFX_USE_GWIN && GWIN_NEED_WIDGET #include <string.h> -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" /* Our listener for events for widgets */ static GListener gl; @@ -302,6 +307,24 @@ void _gwidgetRedraw(GHandle gh) { gw->fnDraw(gw, gw->fnParam); } +void _gwinSendEvent(GHandle gh, GEventType type) { + GSourceListener * psl; + GEventGWin * pge; + + // Trigger a GWIN Event + psl = 0; + while ((psl = geventGetSourceListener(GWIDGET_SOURCE, psl))) { + if (!(pge = (GEventGWin *)geventGetEventBuffer(psl))) + continue; + pge->type = type; + pge->gwin = gh; + #if GWIN_WIDGET_TAGS + pge->tag = (gh->flags & GWIN_FLG_WIDGET) ? ((GWidgetObject *)gh)->tag : 0; + #endif + geventSendEvent(psl); + } +} + void gwinWidgetClearInit(GWidgetInit *pwi) { char *p; unsigned len; diff --git a/src/gwin/gwidget.h b/src/gwin/gwin_widget.h index bd1ea4c8..81c76263 100644 --- a/src/gwin/gwidget.h +++ b/src/gwin/gwin_widget.h @@ -6,7 +6,7 @@ */ /** - * @file src/gwin/gwidget.h + * @file src/gwin/gwin_widget.h * @brief GWIN Widgets header file. * * @defgroup Widget Widget @@ -23,7 +23,7 @@ #ifndef _GWIDGET_H #define _GWIDGET_H -/* This file is included within "gwin/gwin.h" */ +/* This file is included within "src/gwin/sys_defs.h" */ // Forward definition struct GWidgetObject; @@ -135,6 +135,36 @@ typedef struct GWidgetObject { * won't support it even with special flags. */ +/** + * @brief A Generic GWIN Event + * @note All gwin windows when sending events will either use this structure or a + * structure that is 100% compatible except that it may also have extra fields. + * @note There are currently no GEventGWin listening flags - use 0 as the flags to @p gwinAttachListener() + * + * @{ + */ +typedef struct GEventGWin { + GEventType type; // The type of this event + GHandle gwin; // The gwin window handle + #if GWIN_NEED_WIDGET && GWIN_WIDGET_TAGS + WidgetTag tag; // The tag (if applicable) + #endif +} GEventGWin; +/** @} */ + +/** + * @brief The list of predefined GWIN events. + * @note The definition of an event type does not mean it is always sent. For example, + * close events are sent by Frame windows but by little else. They are normally + * only sent if there is a specific reason that the event should be sent. + * @{ + */ +#define GEVENT_GWIN_OPEN (GEVENT_GWIN_FIRST+0x00) +#define GEVENT_GWIN_CLOSE (GEVENT_GWIN_FIRST+0x01) +#define GEVENT_GWIN_RESIZE (GEVENT_GWIN_FIRST+0x02) +#define GEVENT_GWIN_CTRL_FIRST (GEVENT_GWIN_FIRST+0x40) +/** @} */ + #ifdef __cplusplus extern "C" { #endif @@ -330,31 +360,31 @@ bool_t gwinAttachListener(GListener *pl); /* Include extra widget types */ #if GWIN_NEED_BUTTON || defined(__DOXYGEN__) - #include "src/gwin/button.h" + #include "gwin_button.h" #endif #if GWIN_NEED_SLIDER || defined(__DOXYGEN__) - #include "src/gwin/slider.h" + #include "gwin_slider.h" #endif #if GWIN_NEED_CHECKBOX || defined(__DOXYGEN__) - #include "src/gwin/checkbox.h" + #include "gwin_checkbox.h" #endif #if GWIN_NEED_RADIO || defined(__DOXYGEN__) - #include "src/gwin/radio.h" + #include "gwin_radio.h" #endif #if GWIN_NEED_LABEL || defined(__DOXYGEN__) - #include "src/gwin/label.h" + #include "gwin_label.h" #endif #if GWIN_NEED_LIST || defined(__DOXYGEN__) - #include "src/gwin/list.h" + #include "gwin_list.h" #endif #if GWIN_NEED_PROGRESSBAR || defined(__DOXYGEN__) - #include "src/gwin/progressbar.h" + #include "gwin_progressbar.h" #endif #endif /* _GWIDGET_H */ diff --git a/src/gwin/gwm.c b/src/gwin/gwin_wm.c index ba7a132a..92d68c7b 100644 --- a/src/gwin/gwm.c +++ b/src/gwin/gwin_wm.c @@ -5,6 +5,11 @@ * http://ugfx.org/license.html */ +/** + * @file src/gwin/gwin_wm.c + * @brief GWIN sub-system window manager code + */ + #include "gfx.h" #if GFX_USE_GWIN && !GWIN_NEED_WINDOWMANAGER @@ -13,7 +18,7 @@ */ - #include "src/gwin/class_gwin.h" + #include "gwin_class.h" // Needed if there is no window manager #define MIN_WIN_WIDTH 1 @@ -147,7 +152,7 @@ #if GFX_USE_GWIN && GWIN_NEED_WINDOWMANAGER -#include "src/gwin/class_gwin.h" +#include "gwin_class.h" /*----------------------------------------------- * Data diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h index 4b103d11..5e08f7a2 100644 --- a/src/gwin/sys_defs.h +++ b/src/gwin/sys_defs.h @@ -950,25 +950,26 @@ extern "C" { /* Include widgets */ #if GWIN_NEED_WIDGET || defined(__DOXYGEN__) - #include "src/gwin/gwidget.h" + #include "gwin_widget.h" #endif /* Include containers */ #if GWIN_NEED_CONTAINERS || defined(__DOXYGEN__) - #include "src/gwin/gcontainer.h" + #include "gwin_container.h" #endif /* Include vanilla window objects */ #if GWIN_NEED_CONSOLE || defined(__DOXYGEN__) - #include "src/gwin/console.h" + #include "gwin_console.h" #endif - #if GWIN_NEED_GRAPH || defined(__DOXYGEN__) - #include "src/gwin/graph.h" + #include "gwin_graph.h" #endif - #if GWIN_NEED_IMAGE || defined(__DOXYGEN__) - #include "src/gwin/gimage.h" + #include "gwin_image.h" + #endif + #if GWIN_NEED_GL3D || defined(__DOXYGEN__) + #include "gwin_gl3d.h" #endif #endif /* GFX_USE_GWIN */ diff --git a/src/gwin/sys_make.mk b/src/gwin/sys_make.mk index 95a2ba84..81277a4e 100644 --- a/src/gwin/sys_make.mk +++ b/src/gwin/sys_make.mk @@ -1,16 +1,18 @@ -GFXSRC += $(GFXLIB)/src/gwin/gwin.c \ - $(GFXLIB)/src/gwin/gwidget.c \ - $(GFXLIB)/src/gwin/gwm.c \ - $(GFXLIB)/src/gwin/console.c \ - $(GFXLIB)/src/gwin/graph.c \ - $(GFXLIB)/src/gwin/button.c \ - $(GFXLIB)/src/gwin/slider.c \ - $(GFXLIB)/src/gwin/checkbox.c \ - $(GFXLIB)/src/gwin/gimage.c \ - $(GFXLIB)/src/gwin/label.c \ - $(GFXLIB)/src/gwin/radio.c \ - $(GFXLIB)/src/gwin/list.c \ - $(GFXLIB)/src/gwin/progressbar.c \ - $(GFXLIB)/src/gwin/gcontainer.c \ - $(GFXLIB)/src/gwin/frame.c \ - +GFXSRC += $(GFXLIB)/src/gwin/gwin_gwin.c \ + $(GFXLIB)/src/gwin/gwin_widget.c \ + $(GFXLIB)/src/gwin/gwin_wm.c \ + $(GFXLIB)/src/gwin/gwin_console.c \ + $(GFXLIB)/src/gwin/gwin_graph.c \ + $(GFXLIB)/src/gwin/gwin_button.c \ + $(GFXLIB)/src/gwin/gwin_slider.c \ + $(GFXLIB)/src/gwin/gwin_checkbox.c \ + $(GFXLIB)/src/gwin/gwin_image.c \ + $(GFXLIB)/src/gwin/gwin_label.c \ + $(GFXLIB)/src/gwin/gwin_radio.c \ + $(GFXLIB)/src/gwin/gwin_list.c \ + $(GFXLIB)/src/gwin/gwin_progressbar.c \ + $(GFXLIB)/src/gwin/gwin_container.c \ + $(GFXLIB)/src/gwin/gwin_frame.c \ + $(GFXLIB)/src/gwin/gwin_gl3d.c \ + +GFXINC += $(GFXLIB)/3rdparty/tinygl-0.4-ugfx/include diff --git a/src/gwin/sys_options.h b/src/gwin/sys_options.h index d5240556..199cad5b 100644 --- a/src/gwin/sys_options.h +++ b/src/gwin/sys_options.h @@ -73,6 +73,13 @@ #define GWIN_NEED_GRAPH FALSE #endif /** + * @brief Should gl3d functions be included. + * @details Defaults to FALSE + */ + #ifndef GWIN_NEED_GL3D + #define GWIN_NEED_GL3D FALSE + #endif + /** * @brief Should button functions be included. * @details Defaults to FALSE */ |