Reinsertion of doxygen headers

Reinsertion of doxygen headers that got lost in license change
ugfx_release_2.6
Andrew Hannam 2013-05-06 14:44:47 +10:00
parent bbfeec2dd7
commit 3374aa25c6
31 changed files with 1276 additions and 900 deletions

View File

@ -5,6 +5,15 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file drivers/gadc/AT91SAM7/gadc_lld.c
* @brief GADC - Periodic ADC driver source file for the AT91SAM7 cpu.
*
* @defgroup Driver Driver
* @ingroup GADC
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"

View File

@ -4,6 +4,15 @@
*
* http://chibios-gfx.com/license.html
*/
/**
* @file drivers/gaudin/gadc/gaudin_lld.c
* @brief GAUDIN - Driver file for using the cpu ADC (via GADC).
*
* @addtogroup GAUDIN
*
* @{
*/
#include "ch.h"
#include "hal.h"

View File

@ -4,19 +4,29 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5
#define GINPUT_MOUSE_READ_CYCLES 4
#define GINPUT_MOUSE_POLL_PERIOD 25
#define GINPUT_MOUSE_MAX_CLICK_JITTER 10
#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
#define GINPUT_MOUSE_CLICK_TIME 500
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */
/**
* @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h
* @brief GINPUT LLD header file for mouse/touch driver.
*
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5
#define GINPUT_MOUSE_READ_CYCLES 4
#define GINPUT_MOUSE_POLL_PERIOD 25
#define GINPUT_MOUSE_MAX_CLICK_JITTER 10
#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
#define GINPUT_MOUSE_CLICK_TIME 500
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */

View File

@ -4,19 +4,29 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 12
#define GINPUT_MOUSE_READ_CYCLES 4
#define GINPUT_MOUSE_POLL_PERIOD 25
#define GINPUT_MOUSE_MAX_CLICK_JITTER 2
#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
#define GINPUT_MOUSE_CLICK_TIME 500
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */
/**
* @file drivers/ginput/touch/MCU/ginput_lld_mouse_config.h
* @brief GINPUT LLD header file for touch driver.
*
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 12
#define GINPUT_MOUSE_READ_CYCLES 4
#define GINPUT_MOUSE_POLL_PERIOD 25
#define GINPUT_MOUSE_MAX_CLICK_JITTER 2
#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
#define GINPUT_MOUSE_CLICK_TIME 500
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */

View File

@ -4,23 +4,33 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5
#define GINPUT_MOUSE_READ_CYCLES 1
#define GINPUT_MOUSE_POLL_PERIOD 25
#define GINPUT_MOUSE_MAX_CLICK_JITTER 10
#define GINPUT_MOUSE_MAX_MOVE_JITTER 5
#define GINPUT_MOUSE_CLICK_TIME 450
/* default values - over write these in your boad files */
#define STMP811_SLOWER_RESPONSE FALSE
#define STMP811_NO_GPIO_IRQPIN FALSE
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */
/**
* @file drivers/ginput/touch/STMPE811/ginput_lld_mouse_config.h
* @brief GINPUT LLD header file for mouse/touch driver.
*
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5
#define GINPUT_MOUSE_READ_CYCLES 1
#define GINPUT_MOUSE_POLL_PERIOD 25
#define GINPUT_MOUSE_MAX_CLICK_JITTER 10
#define GINPUT_MOUSE_MAX_MOVE_JITTER 5
#define GINPUT_MOUSE_CLICK_TIME 450
/* default values - over write these in your boad files */
#define STMP811_SLOWER_RESPONSE FALSE
#define STMP811_NO_GPIO_IRQPIN FALSE
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */

View File

@ -4,37 +4,47 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
// This driver supports being both a mouse or a touch device (we don't actually know which it really is)
// When operating in mouse mode a long left button click does not generate a context click.
// When operating in touch mode we allow sloppier clicks etc
#if 1
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE
#define GINPUT_MOUSE_CLICK_TIME TIME_INFINITE // Long click != Context Click
#define GINPUT_MOUSE_NEED_CALIBRATION FALSE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_READ_CYCLES 1
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR -1
#define GINPUT_MOUSE_MAX_CLICK_JITTER 0
#define GINPUT_MOUSE_MAX_MOVE_JITTER 0
#else
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_CLICK_TIME 700 // Long click = Context Click
#define GINPUT_MOUSE_NEED_CALIBRATION FALSE // Can be set to TRUE just for testing
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_READ_CYCLES 1
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 2
#define GINPUT_MOUSE_MAX_CLICK_JITTER 2
#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
#endif
// This driver supports both an "interrupt" mode, and a polled mode
#define GINPUT_MOUSE_POLL_PERIOD TIME_INFINITE // Interrupt driven by the Window thread
//#define GINPUT_MOUSE_POLL_PERIOD 25 // Poll driven
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */
/**
* @file drivers/multiple/Win32/ginput_lld_mouse_config.h
* @brief GINPUT LLD header file for mouse/touch driver.
*
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
// This driver supports being both a mouse or a touch device (we don't actually know which it really is)
// When operating in mouse mode a long left button click does not generate a context click.
// When operating in touch mode we allow sloppier clicks etc
#if 1
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE
#define GINPUT_MOUSE_CLICK_TIME TIME_INFINITE // Long click != Context Click
#define GINPUT_MOUSE_NEED_CALIBRATION FALSE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_READ_CYCLES 1
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR -1
#define GINPUT_MOUSE_MAX_CLICK_JITTER 0
#define GINPUT_MOUSE_MAX_MOVE_JITTER 0
#else
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_CLICK_TIME 700 // Long click = Context Click
#define GINPUT_MOUSE_NEED_CALIBRATION FALSE // Can be set to TRUE just for testing
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_READ_CYCLES 1
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 2
#define GINPUT_MOUSE_MAX_CLICK_JITTER 2
#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
#endif
// This driver supports both an "interrupt" mode, and a polled mode
#define GINPUT_MOUSE_POLL_PERIOD TIME_INFINITE // Interrupt driven by the Window thread
//#define GINPUT_MOUSE_POLL_PERIOD 25 // Poll driven
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */

View File

@ -5,6 +5,35 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gadc/gadc.h
* @brief GADC - Periodic ADC subsystem header file.
*
* @addtogroup GADC
*
* @details The reason why ChibiOS/GFX has it's own ADC abstraction is because
* the Chibi-OS drivers are very CPU specific and do not
* provide a way across all hardware platforms to create periodic
* ADC conversions. There are also issues with devices with different
* characteristics or periodic requirements on the same ADC
* device (but different channels). This layer attempts to solve these
* problems to provide a architecture neutral API. It also provides extra
* features such as multi-buffer chaining for high speed ADC sources.
* It provides one high speed virtual ADC device (eg a microphone) and
* numerous low speed (less than 100Hz) virtual ADC devices (eg dials,
* temperature sensors etc). The high speed device has timer based polling
* to ensure exact conversion periods and a buffer management system.
* The low speed devices are assumed to be non-critical timing devices
* and do not have any buffer management.
* Note that while only one high speed device has been provided it can
* be used to read multiple physical ADC channels on the one physical
* ADC device.
* All callback routines are thread based unlike the Chibi-OS interrupt based
* routines.
*
* @{
*/
#ifndef _GADC_H
#define _GADC_H

View File

@ -5,6 +5,15 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gadc/lld/gadc_lld.h
* @brief GADC - Periodic ADC driver header file.
*
* @defgroup Driver Driver
* @ingroup GADC
* @{
*/
#ifndef _GADC_LLD_H
#define _GADC_LLD_H

View File

@ -5,6 +5,15 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gaudin/gaudin.h
* @brief GAUDIN - Audio Input subsystem header file.
*
* @addtogroup GAUDIN
*
* @{
*/
#ifndef _GAUDIN_H
#define _GAUDIN_H

View File

@ -5,6 +5,15 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gaudin/lld/gaudin_lld.h
* @brief GAUDIN - Audio Input driver header file.
*
* @defgroup Driver Driver
* @ingroup GAUDIN
* @{
*/
#ifndef _GAUDIN_LLD_H
#define _GAUDIN_LLD_H

View File

@ -5,6 +5,15 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gaudout/gaudout.h
* @brief GAUDOUT - Audio Output subsystem header file.
*
* @addtogroup GAUDOUT
*
* @{
*/
#ifndef _GAUDOUT_H
#define _GAUDOUT_H

View File

@ -4,6 +4,20 @@
*
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gevent/gevent.h
* @brief GEVENT GFX User Event subsystem header file.
*
* @addtogroup GEVENT
*
* @details GEVENT provides a simple to use but yet powerful event
* system.
*
* @pre GFX_USE_GEVENT must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GEVENT_H
#define _GEVENT_H

View File

@ -4,6 +4,22 @@
*
* http://chibios-gfx.com/license.html
*/
/**
* @file include/ginput/dial.h
* @brief GINPUT GFX User Input subsystem header file.
*
* @defgroup Dial Dial
* @ingroup GINPUT
*
* @details A dial provides a powerful way to navigate through menus
* on a display.
*
* @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
* @pre GINPUT_NEED_DIAL must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GINPUT_DIAL_H
#define _GINPUT_DIAL_H

View File

@ -4,32 +4,46 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _GINPUT_H
#define _GINPUT_H
#include "gfx.h"
#if GFX_USE_GINPUT || defined(__DOXYGEN__)
/* How to use...
1. Get source handles for all the inputs you are interested in.
- Attempting to get a handle for one instance of an input more than once will return the same handle
2. Create a listener
3. Assign inputs to your listener.
- Inputs can be assigned or released from a listener at any time.
- An input can be assigned to more than one listener.
4. Loop on getting listener events
5. When complete destroy the listener
*/
// Include various ginput types
#include "ginput/mouse.h"
#include "ginput/keyboard.h"
#include "ginput/toggle.h"
#include "ginput/dial.h"
#endif /* GFX_USE_GINPUT */
#endif /* _GINPUT_H */
/** @} */
/**
* @file include/ginput/ginput.h
* @brief GINPUT GFX User Input subsystem header file.
*
* @addtogroup GINPUT
*
* @details GINPUT provides an easy and common interface to use different input devices
* such as touchscreens and mices.
*
* @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GINPUT_H
#define _GINPUT_H
#include "gfx.h"
#if GFX_USE_GINPUT || defined(__DOXYGEN__)
/* How to use...
1. Get source handles for all the inputs you are interested in.
- Attempting to get a handle for one instance of an input more than once will return the same handle
2. Create a listener
3. Assign inputs to your listener.
- Inputs can be assigned or released from a listener at any time.
- An input can be assigned to more than one listener.
4. Loop on getting listener events
5. When complete destroy the listener
*/
// Include various ginput types
#include "ginput/mouse.h"
#include "ginput/keyboard.h"
#include "ginput/toggle.h"
#include "ginput/dial.h"
#endif /* GFX_USE_GINPUT */
#endif /* _GINPUT_H */
/** @} */

View File

@ -4,116 +4,125 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _GINPUT_KEYBOARD_H
#define _GINPUT_KEYBOARD_H
#if GINPUT_NEED_KEYBOARD || defined(__DOXYGEN__)
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
#define GINPUT_KEYBOARD_NUM_PORTS 1 // The total number of keyboard inputs
// Event types for various ginput sources
#define GEVENT_KEYBOARD (GEVENT_GINPUT_FIRST+2)
typedef struct GEventKeyboard_t {
GEventType type; // The type of this event (GEVENT_KEYBOARD)
uint16_t instance; // The keyboard instance
char c; // The Ascii code for the current key press.
// The only possible values are 0(NUL), 8(BS), 9(TAB), 13(CR), 27(ESC), 32(SPACE) to 126(~), 127(DEL)
// 0 indicates an extended only key.
uint16_t code; // An extended keyboard code. Codes less than 128 match their ascii equivelent.
#define GKEY_NULL 0
#define GKEY_BACKSPACE 8
#define GKEY_TAB 9
#define GKEY_CR 13
#define GKEY_ESC 27
#define GKEY_SPACE 32
#define GKEY_DEL 127
#define GKEY_UP 0x0101
#define GKEY_DOWN 0x0102
#define GKEY_LEFT 0x0103
#define GKEY_RIGHT 0x0104
#define GKEY_HOME 0x0105
#define GKEY_END 0x0106
#define GKEY_PAGEUP 0x0107
#define GKEY_PAGEDOWN 0x0108
#define GKEY_INSERT 0x0109
#define GKEY_DELETE 0x010A
#define GKEY_SHIFT 0x0201
#define GKEY_CNTRL 0x0202
#define GKEY_ALT 0x0203
#define GKEY_WINKEY 0x0204
#define GKEY_RCLKEY 0x0205
#define GKEY_FNKEY 0x0206
#define GKEY_FN1 0x0301
#define GKEY_FN2 0x0302
#define GKEY_FN3 0x0303
#define GKEY_FN4 0x0304
#define GKEY_FN5 0x0305
#define GKEY_FN6 0x0306
#define GKEY_FN7 0x0307
#define GKEY_FN8 0x0308
#define GKEY_FN9 0x0309
#define GKEY_FN10 0x030A
#define GKEY_FN11 0x030B
#define GKEY_FN12 0x030C
uint16_t current_buttons; // A bit is set to indicate various meta status.
#define GMETA_KEY_DOWN 0x0001
#define GMETA_KEY_SHIFT 0x0002
#define GMETA_KEY_CNTRL 0x0004
#define GMETA_KEY_ALT 0x0008
#define GMETA_KEY_WINKEY 0x0010
#define GMETA_KEY_RCLKKEY 0x0020
#define GMETA_KEY_FN 0x0040
#define GMETA_KEY_MISSED_EVENT 0x8000
uint16_t last_buttons; // The value of current_buttons on the last event
} GEventKeyboard;
// Keyboard Listen Flags - passed to geventAddSourceToListener()
#define GLISTEN_KEYREPEATS 0x0001 // Return key repeats (where the key is held down to get a repeat character)
#define GLISTEN_KEYCODES 0x0002 // Return all key presses including extended code key presses (not just ascii codes)
#define GLISTEN_KEYALL 0x0004 // Return keyup's, keydown's and everything in between (but not repeats unless GLISTEN_KEYREPEATS is set).
#define GLISTEN_KEYSINGLE 0x8000 // Return only when one particular extended code key is pressed or released. The particular extended code is OR'd into this value
// eg. (GLISTEN_KEYSINGLE | GKEY_CR)
// No other flags may be set with this flag.
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Create a keyboard input instance
*
* @param[in] instance The ID of the keyboard input instance (from 0 to 9999)
*
* @return The source handle of the created input instance
*/
GSourceHandle ginputGetKeyboard(uint16_t instance);
/**
* @brief Get the current keyboard status
*
* @param[in] instance The ID of the keyboard input instance
* @param[in] pkeyboard The keyboard event struct
*
* @return Returns FALSE on an error (eg invalid instance)
*/
bool_t ginputGetKeyboardStatus(uint16_t instance, GEventKeyboard *pkeyboard);
#ifdef __cplusplus
}
#endif
#endif /* GINPUT_NEED_KEYBOARD */
#endif /* _GINPUT_KEYBOARD_H */
/** @} */
/**
* @file include/ginput/keyboard.h
* @brief GINPUT GFX User Input subsystem header file.
*
* @defgroup Keyboard Keyboard
* @ingroup GINPUT
* @{
*/
#ifndef _GINPUT_KEYBOARD_H
#define _GINPUT_KEYBOARD_H
#if GINPUT_NEED_KEYBOARD || defined(__DOXYGEN__)
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
#define GINPUT_KEYBOARD_NUM_PORTS 1 // The total number of keyboard inputs
// Event types for various ginput sources
#define GEVENT_KEYBOARD (GEVENT_GINPUT_FIRST+2)
typedef struct GEventKeyboard_t {
GEventType type; // The type of this event (GEVENT_KEYBOARD)
uint16_t instance; // The keyboard instance
char c; // The Ascii code for the current key press.
// The only possible values are 0(NUL), 8(BS), 9(TAB), 13(CR), 27(ESC), 32(SPACE) to 126(~), 127(DEL)
// 0 indicates an extended only key.
uint16_t code; // An extended keyboard code. Codes less than 128 match their ascii equivelent.
#define GKEY_NULL 0
#define GKEY_BACKSPACE 8
#define GKEY_TAB 9
#define GKEY_CR 13
#define GKEY_ESC 27
#define GKEY_SPACE 32
#define GKEY_DEL 127
#define GKEY_UP 0x0101
#define GKEY_DOWN 0x0102
#define GKEY_LEFT 0x0103
#define GKEY_RIGHT 0x0104
#define GKEY_HOME 0x0105
#define GKEY_END 0x0106
#define GKEY_PAGEUP 0x0107
#define GKEY_PAGEDOWN 0x0108
#define GKEY_INSERT 0x0109
#define GKEY_DELETE 0x010A
#define GKEY_SHIFT 0x0201
#define GKEY_CNTRL 0x0202
#define GKEY_ALT 0x0203
#define GKEY_WINKEY 0x0204
#define GKEY_RCLKEY 0x0205
#define GKEY_FNKEY 0x0206
#define GKEY_FN1 0x0301
#define GKEY_FN2 0x0302
#define GKEY_FN3 0x0303
#define GKEY_FN4 0x0304
#define GKEY_FN5 0x0305
#define GKEY_FN6 0x0306
#define GKEY_FN7 0x0307
#define GKEY_FN8 0x0308
#define GKEY_FN9 0x0309
#define GKEY_FN10 0x030A
#define GKEY_FN11 0x030B
#define GKEY_FN12 0x030C
uint16_t current_buttons; // A bit is set to indicate various meta status.
#define GMETA_KEY_DOWN 0x0001
#define GMETA_KEY_SHIFT 0x0002
#define GMETA_KEY_CNTRL 0x0004
#define GMETA_KEY_ALT 0x0008
#define GMETA_KEY_WINKEY 0x0010
#define GMETA_KEY_RCLKKEY 0x0020
#define GMETA_KEY_FN 0x0040
#define GMETA_KEY_MISSED_EVENT 0x8000
uint16_t last_buttons; // The value of current_buttons on the last event
} GEventKeyboard;
// Keyboard Listen Flags - passed to geventAddSourceToListener()
#define GLISTEN_KEYREPEATS 0x0001 // Return key repeats (where the key is held down to get a repeat character)
#define GLISTEN_KEYCODES 0x0002 // Return all key presses including extended code key presses (not just ascii codes)
#define GLISTEN_KEYALL 0x0004 // Return keyup's, keydown's and everything in between (but not repeats unless GLISTEN_KEYREPEATS is set).
#define GLISTEN_KEYSINGLE 0x8000 // Return only when one particular extended code key is pressed or released. The particular extended code is OR'd into this value
// eg. (GLISTEN_KEYSINGLE | GKEY_CR)
// No other flags may be set with this flag.
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Create a keyboard input instance
*
* @param[in] instance The ID of the keyboard input instance (from 0 to 9999)
*
* @return The source handle of the created input instance
*/
GSourceHandle ginputGetKeyboard(uint16_t instance);
/**
* @brief Get the current keyboard status
*
* @param[in] instance The ID of the keyboard input instance
* @param[in] pkeyboard The keyboard event struct
*
* @return Returns FALSE on an error (eg invalid instance)
*/
bool_t ginputGetKeyboardStatus(uint16_t instance, GEventKeyboard *pkeyboard);
#ifdef __cplusplus
}
#endif
#endif /* GINPUT_NEED_KEYBOARD */
#endif /* _GINPUT_KEYBOARD_H */
/** @} */

View File

@ -5,6 +5,15 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/ginput/lld/dial.h
* @brief GINPUT header file for dial drivers.
*
* @defgroup Dial Dial
* @ingroup GINPUT
* @{
*/
#ifndef _LLD_GINPUT_DIAL_H
#define _LLD_GINPUT_DIAL_H

View File

@ -5,6 +5,15 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/ginput/lld/mouse.h
* @brief GINPUT LLD header file for mouse/touch drivers.
*
* @defgroup Mouse Mouse
* @ingroup GINPUT
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_H
#define _LLD_GINPUT_MOUSE_H

View File

@ -4,49 +4,58 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _LLD_GINPUT_TOGGLE_H
#define _LLD_GINPUT_TOGGLE_H
#if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__)
// Describes how the toggle bits are obtained
typedef struct GToggleConfig_t {
void *id;
unsigned mask;
unsigned invert;
iomode_t mode;
} GToggleConfig;
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
extern const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES];
void ginput_lld_toggle_init(const GToggleConfig *ptc);
unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc);
/* This routine is provided to low level drivers to wakeup a value read from a thread context.
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
*/
void ginputToggleWakeup(void);
/* This routine is provided to low level drivers to wakeup a value read from an ISR
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
*/
void ginputToggleWakeupI(void);
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
#endif /* _LLD_GINPUT_TOGGLE_H */
/** @} */
/**
* @file include/ginput/lld/toggle.h
* @brief GINPUT header file for toggle drivers.
*
* @defgroup Toggle Toggle
* @ingroup GINPUT
* @{
*/
#ifndef _LLD_GINPUT_TOGGLE_H
#define _LLD_GINPUT_TOGGLE_H
#if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__)
// Describes how the toggle bits are obtained
typedef struct GToggleConfig_t {
void *id;
unsigned mask;
unsigned invert;
iomode_t mode;
} GToggleConfig;
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
extern const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES];
void ginput_lld_toggle_init(const GToggleConfig *ptc);
unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc);
/* This routine is provided to low level drivers to wakeup a value read from a thread context.
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
*/
void ginputToggleWakeup(void);
/* This routine is provided to low level drivers to wakeup a value read from an ISR
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
*/
void ginputToggleWakeupI(void);
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
#endif /* _LLD_GINPUT_TOGGLE_H */
/** @} */

View File

@ -4,140 +4,156 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _GINPUT_MOUSE_H
#define _GINPUT_MOUSE_H
#if GINPUT_NEED_MOUSE || defined(__DOXYGEN__)
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
/* This type definition is also used by touch */
typedef struct GEventMouse_t {
GEventType type; // The type of this event (GEVENT_MOUSE or GEVENT_TOUCH)
uint16_t instance; // The mouse/touch instance
coord_t x, y, z; // The position of the mouse.
// - For touch devices, Z is the current pressure if supported (otherwise 0)
// - For mice, Z is the 3rd dimension if supported (otherwise 0)
uint16_t current_buttons; // A bit is set if the button is down.
// - For touch only bit 0 is relevant
// - For mice the order of the buttons is (from 0 to n) left, right, middle, any other buttons
// - Bit 15 being set indicates that an important mouse event has been missed.
#define GINPUT_MOUSE_BTN_LEFT 0x0001
#define GINPUT_MOUSE_BTN_RIGHT 0x0002
#define GINPUT_MOUSE_BTN_MIDDLE 0x0004
#define GINPUT_MOUSE_BTN_4 0x0008
#define GINPUT_MISSED_MOUSE_EVENT 0x8000
#define GINPUT_TOUCH_PRESSED GINPUT_MOUSE_BTN_LEFT
uint16_t last_buttons; // The value of current_buttons on the last event
enum GMouseMeta_e {
GMETA_NONE = 0, // There is no meta event currently happening
GMETA_MOUSE_DOWN = 1, // Button 0 has just gone down
GMETA_MOUSE_UP = 2, // Button 0 has just gone up
GMETA_MOUSE_CLICK = 4, // Button 0 has just gone through a short down - up cycle
GMETA_MOUSE_CXTCLICK = 8 // For mice - The right button has just been depressed
// For touch - a long press has just occurred
} meta;
} GEventMouse;
// Mouse/Touch Listen Flags - passed to geventAddSourceToListener()
#define GLISTEN_MOUSEMETA 0x0001 // Create events for meta events such as CLICK and CXTCLICK
#define GLISTEN_MOUSEDOWNMOVES 0x0002 // Creates mouse move events when the primary mouse button is down (touch is on the surface)
#define GLISTEN_MOUSEUPMOVES 0x0004 // Creates mouse move events when the primary mouse button is up (touch is off the surface - if the hardware allows).
#define GLISTEN_MOUSENOFILTER 0x0008 // Don't filter out mouse moves where the position hasn't changed.
#define GLISTEN_TOUCHMETA GLISTEN_MOUSEMETA
#define GLISTEN_TOUCHDOWNMOVES GLISTEN_MOUSEDOWNMOVES
#define GLISTEN_TOUCHUPMOVES GLISTEN_MOUSEUPMOVES
#define GLISTEN_TOUCHNOFILTER GLISTEN_MOUSENOFILTER
#define GINPUT_MOUSE_NUM_PORTS 1 // The total number of mouse/touch inputs supported
// Event types for the mouse ginput source
#define GEVENT_MOUSE (GEVENT_GINPUT_FIRST+0)
#define GEVENT_TOUCH (GEVENT_GINPUT_FIRST+1)
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Creates an instance of a mouse and returns the Source handler
* @note hack: if the instance is 9999, no calibration will be performed!
*
* @param[in] instance The ID of the mouse input instance (from 0 to 9999)
*
* @return The source handle of the created instance
*/
GSourceHandle ginputGetMouse(uint16_t instance);
/**
* @brief Get the current mouse position and button status
* @note Unlinke a listener event, this status cannot record meta events such as
* "CLICK".
*
* @param[in] instance The ID of the mouse input instance
* @param[in] pmouse The mouse event
*
* @return FALSE on an error (eg. invalid instance)
*/
bool_t ginputGetMouseStatus(uint16_t instance, GEventMouse *pmouse);
/**
* @brief Performs a calibration
*
* @param[in] instance The ID of the mouse input instance
*
* @return FALSE if the driver dosen't support a calibration of if the handle is invalid
*/
bool_t ginputCalibrateMouse(uint16_t instance);
/* Set the routines to save and fetch calibration data.
* This function should be called before first calling ginputGetMouse() for a particular instance
* as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it.
* If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the data is has already obtained.
* The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine.
*/
typedef void (*GMouseCalibrationSaveRoutine)(uint16_t instance, const uint8_t *calbuf, size_t sz); // Save calibration data
typedef const char * (*GMouseCalibrationLoadRoutine)(uint16_t instance); // Load calibration data (returns NULL if not data saved)
/**
* @brief Set the routines to store and restore calibration data
*
* @details This function should be called before first calling ginputGetMouse() for a particular instance
* as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it.
* If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the
* data is has already obtained.
* The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine.
*
* @param[in] instance The ID of the mouse input instance
* @param[in] fnsave The routine to save the data
* @param[in] fnload The routine to restore the data
* @param[in] requireFree ToDo
*/
void ginputSetMouseCalibrationRoutines(uint16_t instance, GMouseCalibrationSaveRoutine fnsave, GMouseCalibrationLoadRoutine fnload, bool_t requireFree);
/**
* @brief Test if a particular mouse/touch instance requires routines to save it's alibration data
* @note Not implemented yet
*
* @param[in] instance The ID of the mouse input instance
*
* @return TRUE if needed
*/
bool_t ginputRequireMouseCalibrationStorage(uint16_t instance);
#ifdef __cplusplus
}
#endif
#endif /* GINPUT_NEED_MOUSE */
#endif /* _GINPUT_MOUSE_H */
/** @} */
/**
* @file include/ginput/mouse.h
* @brief GINPUT GFX User Input subsystem header file for mouse and touch.
*
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @details GINPUT allows it to easily interface touchscreens and mices to
* your application.
*
* @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
* @pre GINPUT_NEED_MOUSE must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GINPUT_MOUSE_H
#define _GINPUT_MOUSE_H
#if GINPUT_NEED_MOUSE || defined(__DOXYGEN__)
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
/* This type definition is also used by touch */
typedef struct GEventMouse_t {
GEventType type; // The type of this event (GEVENT_MOUSE or GEVENT_TOUCH)
uint16_t instance; // The mouse/touch instance
coord_t x, y, z; // The position of the mouse.
// - For touch devices, Z is the current pressure if supported (otherwise 0)
// - For mice, Z is the 3rd dimension if supported (otherwise 0)
uint16_t current_buttons; // A bit is set if the button is down.
// - For touch only bit 0 is relevant
// - For mice the order of the buttons is (from 0 to n) left, right, middle, any other buttons
// - Bit 15 being set indicates that an important mouse event has been missed.
#define GINPUT_MOUSE_BTN_LEFT 0x0001
#define GINPUT_MOUSE_BTN_RIGHT 0x0002
#define GINPUT_MOUSE_BTN_MIDDLE 0x0004
#define GINPUT_MOUSE_BTN_4 0x0008
#define GINPUT_MISSED_MOUSE_EVENT 0x8000
#define GINPUT_TOUCH_PRESSED GINPUT_MOUSE_BTN_LEFT
uint16_t last_buttons; // The value of current_buttons on the last event
enum GMouseMeta_e {
GMETA_NONE = 0, // There is no meta event currently happening
GMETA_MOUSE_DOWN = 1, // Button 0 has just gone down
GMETA_MOUSE_UP = 2, // Button 0 has just gone up
GMETA_MOUSE_CLICK = 4, // Button 0 has just gone through a short down - up cycle
GMETA_MOUSE_CXTCLICK = 8 // For mice - The right button has just been depressed
// For touch - a long press has just occurred
} meta;
} GEventMouse;
// Mouse/Touch Listen Flags - passed to geventAddSourceToListener()
#define GLISTEN_MOUSEMETA 0x0001 // Create events for meta events such as CLICK and CXTCLICK
#define GLISTEN_MOUSEDOWNMOVES 0x0002 // Creates mouse move events when the primary mouse button is down (touch is on the surface)
#define GLISTEN_MOUSEUPMOVES 0x0004 // Creates mouse move events when the primary mouse button is up (touch is off the surface - if the hardware allows).
#define GLISTEN_MOUSENOFILTER 0x0008 // Don't filter out mouse moves where the position hasn't changed.
#define GLISTEN_TOUCHMETA GLISTEN_MOUSEMETA
#define GLISTEN_TOUCHDOWNMOVES GLISTEN_MOUSEDOWNMOVES
#define GLISTEN_TOUCHUPMOVES GLISTEN_MOUSEUPMOVES
#define GLISTEN_TOUCHNOFILTER GLISTEN_MOUSENOFILTER
#define GINPUT_MOUSE_NUM_PORTS 1 // The total number of mouse/touch inputs supported
// Event types for the mouse ginput source
#define GEVENT_MOUSE (GEVENT_GINPUT_FIRST+0)
#define GEVENT_TOUCH (GEVENT_GINPUT_FIRST+1)
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Creates an instance of a mouse and returns the Source handler
* @note hack: if the instance is 9999, no calibration will be performed!
*
* @param[in] instance The ID of the mouse input instance (from 0 to 9999)
*
* @return The source handle of the created instance
*/
GSourceHandle ginputGetMouse(uint16_t instance);
/**
* @brief Get the current mouse position and button status
* @note Unlinke a listener event, this status cannot record meta events such as
* "CLICK".
*
* @param[in] instance The ID of the mouse input instance
* @param[in] pmouse The mouse event
*
* @return FALSE on an error (eg. invalid instance)
*/
bool_t ginputGetMouseStatus(uint16_t instance, GEventMouse *pmouse);
/**
* @brief Performs a calibration
*
* @param[in] instance The ID of the mouse input instance
*
* @return FALSE if the driver dosen't support a calibration of if the handle is invalid
*/
bool_t ginputCalibrateMouse(uint16_t instance);
/* Set the routines to save and fetch calibration data.
* This function should be called before first calling ginputGetMouse() for a particular instance
* as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it.
* If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the data is has already obtained.
* The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine.
*/
typedef void (*GMouseCalibrationSaveRoutine)(uint16_t instance, const uint8_t *calbuf, size_t sz); // Save calibration data
typedef const char * (*GMouseCalibrationLoadRoutine)(uint16_t instance); // Load calibration data (returns NULL if not data saved)
/**
* @brief Set the routines to store and restore calibration data
*
* @details This function should be called before first calling ginputGetMouse() for a particular instance
* as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it.
* If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the
* data is has already obtained.
* The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine.
*
* @param[in] instance The ID of the mouse input instance
* @param[in] fnsave The routine to save the data
* @param[in] fnload The routine to restore the data
* @param[in] requireFree ToDo
*/
void ginputSetMouseCalibrationRoutines(uint16_t instance, GMouseCalibrationSaveRoutine fnsave, GMouseCalibrationLoadRoutine fnload, bool_t requireFree);
/**
* @brief Test if a particular mouse/touch instance requires routines to save it's alibration data
* @note Not implemented yet
*
* @param[in] instance The ID of the mouse input instance
*
* @return TRUE if needed
*/
bool_t ginputRequireMouseCalibrationStorage(uint16_t instance);
#ifdef __cplusplus
}
#endif
#endif /* GINPUT_NEED_MOUSE */
#endif /* _GINPUT_MOUSE_H */
/** @} */

View File

@ -4,81 +4,97 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _GINPUT_TOGGLE_H
#define _GINPUT_TOGGLE_H
#if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__)
/*===========================================================================*/
/* Low Level Driver details and error checks. */
/*===========================================================================*/
// Get the hardware definitions - Number of instances etc.
#include "ginput_lld_toggle_config.h"
#ifndef GINPUT_TOGGLE_POLL_PERIOD
#define GINPUT_TOGGLE_POLL_PERIOD 200
#endif
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
// Event types for various ginput sources
#define GEVENT_TOGGLE (GEVENT_GINPUT_FIRST+3)
typedef struct GEventToggle_t {
GEventType type; // The type of this event (GEVENT_TOGGLE)
uint16_t instance; // The toggle instance
bool_t on; // True if the toggle/button is on
} GEventToggle;
// Toggle Listen Flags - passed to geventAddSourceToListener()
#define GLISTEN_TOGGLE_ON 0x0001 // Return an event when the toggle turns on
#define GLISTEN_TOGGLE_OFF 0x0002 // Return an event when the toggle turns off
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Create a toggle input instance
*
* @param[in] instance The ID of the toggle input instance (from 0 to 9999)
*
* @return The source handle of the created instance
*/
GSourceHandle ginputGetToggle(uint16_t instance);
/**
* @brief Can be used to invert the sense of a toggle
*
* @param[in] instance The ID of the toggle input instance
* @param[in] invert If TRUE, will be inverted
*/
void ginputInvertToggle(uint16_t instance, bool_t invert);
/**
* @brief Get the current toggle status
*
* @param[in] instance The ID of the toggle input instance
* @param[in] ptoggle The toggle event struct
*
* @return Returns FALSE on an error (eg invalid instance)
*/
bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle);
#ifdef __cplusplus
}
#endif
#endif /* GINPUT_NEED_TOGGLE */
#endif /* _GINPUT_TOGGLE_H */
/** @} */
/**
* @file include/ginput/toggle.h
* @brief GINPUT GFX User Input subsystem header file.
*
* @defgroup Toggle Toggle
* @ingroup GINPUT
*
* @details GINPUT allows it to interface toggle buttons easily to your
* application.
*
* @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
* @pre GINPUT_NEED_TOGGLE must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GINPUT_TOGGLE_H
#define _GINPUT_TOGGLE_H
#if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__)
/*===========================================================================*/
/* Low Level Driver details and error checks. */
/*===========================================================================*/
// Get the hardware definitions - Number of instances etc.
#include "ginput_lld_toggle_config.h"
#ifndef GINPUT_TOGGLE_POLL_PERIOD
#define GINPUT_TOGGLE_POLL_PERIOD 200
#endif
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
// Event types for various ginput sources
#define GEVENT_TOGGLE (GEVENT_GINPUT_FIRST+3)
typedef struct GEventToggle_t {
GEventType type; // The type of this event (GEVENT_TOGGLE)
uint16_t instance; // The toggle instance
bool_t on; // True if the toggle/button is on
} GEventToggle;
// Toggle Listen Flags - passed to geventAddSourceToListener()
#define GLISTEN_TOGGLE_ON 0x0001 // Return an event when the toggle turns on
#define GLISTEN_TOGGLE_OFF 0x0002 // Return an event when the toggle turns off
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Create a toggle input instance
*
* @param[in] instance The ID of the toggle input instance (from 0 to 9999)
*
* @return The source handle of the created instance
*/
GSourceHandle ginputGetToggle(uint16_t instance);
/**
* @brief Can be used to invert the sense of a toggle
*
* @param[in] instance The ID of the toggle input instance
* @param[in] invert If TRUE, will be inverted
*/
void ginputInvertToggle(uint16_t instance, bool_t invert);
/**
* @brief Get the current toggle status
*
* @param[in] instance The ID of the toggle input instance
* @param[in] ptoggle The toggle event struct
*
* @return Returns FALSE on an error (eg invalid instance)
*/
bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle);
#ifdef __cplusplus
}
#endif
#endif /* GINPUT_NEED_TOGGLE */
#endif /* _GINPUT_TOGGLE_H */
/** @} */

View File

@ -5,6 +5,15 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gmisc/gmisc.h
* @brief GMISC - Miscellaneous Routines header file.
*
* @addtogroup GAUDIN
*
* @{
*/
#ifndef _GMISC_H
#define _GMISC_H

View File

@ -4,147 +4,167 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _GTIMER_H
#define _GTIMER_H
#include "gfx.h"
#if GFX_USE_GTIMER || defined(__DOXYGEN__)
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
/* Data part of a static GTimer initialiser */
#define _GTIMER_DATA() {0,0,0,0,0,0,0}
/* Static GTimer initialiser */
#define GTIMER_DECL(name) GTimer name = _GTIMER_DATA()
/* A callback function (executed in a thread context) */
typedef void (*GTimerFunction)(void *param);
/**
* @brief A GTimer structure
*/
typedef struct GTimer_t {
GTimerFunction fn;
void *param;
systime_t when;
systime_t period;
uint16_t flags;
struct GTimer_t *next;
struct GTimer_t *prev;
} GTimer;
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialise a timer.
*
* @param[in] pt pointer to a GTimer structure
*
* @api
*/
void gtimerInit(GTimer *pt);
/**
* @brief Set a timer going or alter its properties if it is already going.
*
* @param[in] pt Pointer to a GTimer structure
* @param[in] fn The callback function
* @param[in] param The parameter to pass to the callback function
* @param[in] periodic Is the timer a periodic timer? FALSE is a once-only timer.
* @param[in] millisec The timer period. The following special values are allowed:
* TIME_IMMEDIATE causes the callback function to be called asap.
* A periodic timer with this value will fire once only.
* TIME_INFINITE never timeout (unless triggered by gtimerJab or gtimerJabI)
*
* @note If the timer is already active its properties are updated with the new parameters.
* The current period will be immediately canceled (without the callback function being
* called) and the timer will be restart with the new timer properties.
* @note The callback function should be careful not to over-run the thread stack.
* Define a new value for the macro GTIME_THREAD_STACK_SIZE if you want to
* change the default size.
* @note The callback function should return as quickly as possible as all
* timer callbacks are performed by a single thread. If a callback function
* takes too long it could affect the timer response for other timers.
* @note A timer callback function is not a replacement for a dedicated thread if the
* function wants to perform computationally expensive stuff.
* @note As the callback function is called on GTIMER's thread, the function must make sure it uses
* appropriate synchronisation controls such as semaphores or mutexes around any data
* structures it shares with other threads such as the main application thread.
*
* @api
*/
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, systime_t millisec);
/**
* @brief Stop a timer (periodic or otherwise)
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
*
* @api
*/
void gtimerStop(GTimer *pt);
/**
* @brief Test if a timer is currently active
*
* @param[in] pt Pointer to a GTimer structure
*
* @return TRUE if active, FALSE otherwise
*
* @api
*/
bool_t gtimerIsActive(GTimer *pt);
/**
* @brief Jab a timer causing the current period to immediate expire
* @details The callback function will be called as soon as possible.
*
* @pre Use from a normal thread context.
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
* @note Repeated Jabs before the callback function actually happens are ignored.
*
* @api
*/
void gtimerJab(GTimer *pt);
/**
* @brief Jab a timer causing the current period to immediate expire
* @details The callback function will be called as soon as possible.
*
* @pre Use from an interrupt routine context.
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
* @note Repeated Jabs before the callback function actually happens are ignored.
*
* @iclass
* @api
*/
void gtimerJabI(GTimer *pt);
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_GTIMER */
#endif /* _GTIMER_H */
/** @} */
/**
* @file include/gtimer/gtimer.h
* @brief GTIMER GFX User Timer subsystem header file.
*
* @addtogroup GTIMER
*
* @details The reason why ChibiOS/GFX has it's own timer abstraction is because
* virtual timers provided by ChibiOS/RT are interrupt context only.
* While great for what they are designed for, they make coding of the input
* drivers much more complex.
* For non-performance critical drivers like these input drivers, it would also
* hog an in-ordinate amount of critical (interrupt locked) system time.
* This contrary to the goals of a real-time operating system. So a user-land
* (thread based) timer mechanism is also required.
*
* @pre GFX_USE_GTIMER must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GTIMER_H
#define _GTIMER_H
#include "gfx.h"
#if GFX_USE_GTIMER || defined(__DOXYGEN__)
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
/* Data part of a static GTimer initialiser */
#define _GTIMER_DATA() {0,0,0,0,0,0,0}
/* Static GTimer initialiser */
#define GTIMER_DECL(name) GTimer name = _GTIMER_DATA()
/* A callback function (executed in a thread context) */
typedef void (*GTimerFunction)(void *param);
/**
* @brief A GTimer structure
*/
typedef struct GTimer_t {
GTimerFunction fn;
void *param;
systime_t when;
systime_t period;
uint16_t flags;
struct GTimer_t *next;
struct GTimer_t *prev;
} GTimer;
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialise a timer.
*
* @param[in] pt pointer to a GTimer structure
*
* @api
*/
void gtimerInit(GTimer *pt);
/**
* @brief Set a timer going or alter its properties if it is already going.
*
* @param[in] pt Pointer to a GTimer structure
* @param[in] fn The callback function
* @param[in] param The parameter to pass to the callback function
* @param[in] periodic Is the timer a periodic timer? FALSE is a once-only timer.
* @param[in] millisec The timer period. The following special values are allowed:
* TIME_IMMEDIATE causes the callback function to be called asap.
* A periodic timer with this value will fire once only.
* TIME_INFINITE never timeout (unless triggered by gtimerJab or gtimerJabI)
*
* @note If the timer is already active its properties are updated with the new parameters.
* The current period will be immediately canceled (without the callback function being
* called) and the timer will be restart with the new timer properties.
* @note The callback function should be careful not to over-run the thread stack.
* Define a new value for the macro GTIME_THREAD_STACK_SIZE if you want to
* change the default size.
* @note The callback function should return as quickly as possible as all
* timer callbacks are performed by a single thread. If a callback function
* takes too long it could affect the timer response for other timers.
* @note A timer callback function is not a replacement for a dedicated thread if the
* function wants to perform computationally expensive stuff.
* @note As the callback function is called on GTIMER's thread, the function must make sure it uses
* appropriate synchronisation controls such as semaphores or mutexes around any data
* structures it shares with other threads such as the main application thread.
*
* @api
*/
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, systime_t millisec);
/**
* @brief Stop a timer (periodic or otherwise)
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
*
* @api
*/
void gtimerStop(GTimer *pt);
/**
* @brief Test if a timer is currently active
*
* @param[in] pt Pointer to a GTimer structure
*
* @return TRUE if active, FALSE otherwise
*
* @api
*/
bool_t gtimerIsActive(GTimer *pt);
/**
* @brief Jab a timer causing the current period to immediate expire
* @details The callback function will be called as soon as possible.
*
* @pre Use from a normal thread context.
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
* @note Repeated Jabs before the callback function actually happens are ignored.
*
* @api
*/
void gtimerJab(GTimer *pt);
/**
* @brief Jab a timer causing the current period to immediate expire
* @details The callback function will be called as soon as possible.
*
* @pre Use from an interrupt routine context.
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
* @note Repeated Jabs before the callback function actually happens are ignored.
*
* @iclass
* @api
*/
void gtimerJabI(GTimer *pt);
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_GTIMER */
#endif /* _GTIMER_H */
/** @} */

View File

@ -5,6 +5,22 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gwin/button.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Button Button
* @ingroup GWIN
*
* @details GWIN allows it to easily create buttons with different styles
* and check for different meta states such as: PRESSED, CLICKED,
* RELEASED etc.
*
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
* @pre GWIN_NEED_BUTTON must be set to TRUE in your gfxconf.h
* @{
*/
#ifndef _GWIN_BUTTON_H
#define _GWIN_BUTTON_H

View File

@ -4,113 +4,129 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _GWIN_CONSOLE_H
#define _GWIN_CONSOLE_H
#if GWIN_NEED_CONSOLE || defined(__DOXYGEN__)
/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
#define GW_CONSOLE 0x0001
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
// A console window. Supports wrapped text writing and a cursor.
typedef struct GConsoleObject_t {
GWindowObject gwin;
struct GConsoleWindowStream_t {
const struct GConsoleWindowVMT_t *vmt;
_base_asynchronous_channel_data
} stream;
coord_t cx,cy; // Cursor position
uint8_t fy; // Current font height
uint8_t fp; // Current font inter-character spacing
} GConsoleObject;
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Create a console window.
* @details A console window allows text to be written using chprintf() (and the console functions defined here).
* @brief Text in a console window supports newlines and will wrap text as required.
* @return NULL if there is no resultant drawing area, otherwise a window handle.
*
* @param[in] gc The GConsoleObject structure to initialise. If this is NULL the structure is dynamically allocated.
* @param[in] x,y The screen co-ordinates for the bottom left corner of the window
* @param[in] width The width of the window
* @param[in] height The height of the window
* @param[in] font The font to use
* @note The console is not automatically cleared on creation. You must do that by calling gwinClear() (possibly after changing your background color)
* @note If the dispay does not support scrolling, the window will be cleared when the bottom line is reached.
* @note The default drawing color gets set to White and the background drawing color to Black.
* @note The dimensions and position may be changed to fit on the real screen.
*
* @api
*/
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font);
/**
* @brief Get a stream from a console window suitable for use with chprintf().
* @return The stream handle or NULL if this is not a console window.
*
* @param[in] gh The window handle (must be a console window)
*
* @api
*/
BaseSequentialStream *gwinGetConsoleStream(GHandle gh);
/**
* @brief Put a character at the cursor position in the window.
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
*
* @param[in] gh The window handle (must be a console window)
* @param[in] c The character to draw
*
* @api
*/
void gwinPutChar(GHandle gh, char c);
/**
* @brief Put a string at the cursor position in the window. It will wrap lines as required.
* @note Uses the current foreground color to draw the string and fills the background using the background drawing color
*
* @param[in] gh The window handle (must be a console window)
* @param[in] str The string to draw
*
* @api
*/
void gwinPutString(GHandle gh, const char *str);
/**
* @brief Put the character array at the cursor position in the window. It will wrap lines as required.
* @note Uses the current foreground color to draw the string and fills the background using the background drawing color
*
* @param[in] gh The window handle (must be a console window)
* @param[in] str The string to draw
* @param[in] n The number of characters to draw
*
* @api
*/
void gwinPutCharArray(GHandle gh, const char *str, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* GWIN_NEED_CONSOLE */
#endif /* _GWIN_CONSOLE_H */
/** @} */
/**
* @file include/gwin/console.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Console Console
* @ingroup GWIN
*
* @details GWIN allows it to create a console/terminal like window.
* You can simply use chprintf() to print to the terminal.
*
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
* @pre GWIN_NEED_CONSOLE must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GWIN_CONSOLE_H
#define _GWIN_CONSOLE_H
#if GWIN_NEED_CONSOLE || defined(__DOXYGEN__)
/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
#define GW_CONSOLE 0x0001
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
// A console window. Supports wrapped text writing and a cursor.
typedef struct GConsoleObject_t {
GWindowObject gwin;
struct GConsoleWindowStream_t {
const struct GConsoleWindowVMT_t *vmt;
_base_asynchronous_channel_data
} stream;
coord_t cx,cy; // Cursor position
uint8_t fy; // Current font height
uint8_t fp; // Current font inter-character spacing
} GConsoleObject;
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Create a console window.
* @details A console window allows text to be written using chprintf() (and the console functions defined here).
* @brief Text in a console window supports newlines and will wrap text as required.
* @return NULL if there is no resultant drawing area, otherwise a window handle.
*
* @param[in] gc The GConsoleObject structure to initialise. If this is NULL the structure is dynamically allocated.
* @param[in] x,y The screen co-ordinates for the bottom left corner of the window
* @param[in] width The width of the window
* @param[in] height The height of the window
* @param[in] font The font to use
* @note The console is not automatically cleared on creation. You must do that by calling gwinClear() (possibly after changing your background color)
* @note If the dispay does not support scrolling, the window will be cleared when the bottom line is reached.
* @note The default drawing color gets set to White and the background drawing color to Black.
* @note The dimensions and position may be changed to fit on the real screen.
*
* @api
*/
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font);
/**
* @brief Get a stream from a console window suitable for use with chprintf().
* @return The stream handle or NULL if this is not a console window.
*
* @param[in] gh The window handle (must be a console window)
*
* @api
*/
BaseSequentialStream *gwinGetConsoleStream(GHandle gh);
/**
* @brief Put a character at the cursor position in the window.
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
*
* @param[in] gh The window handle (must be a console window)
* @param[in] c The character to draw
*
* @api
*/
void gwinPutChar(GHandle gh, char c);
/**
* @brief Put a string at the cursor position in the window. It will wrap lines as required.
* @note Uses the current foreground color to draw the string and fills the background using the background drawing color
*
* @param[in] gh The window handle (must be a console window)
* @param[in] str The string to draw
*
* @api
*/
void gwinPutString(GHandle gh, const char *str);
/**
* @brief Put the character array at the cursor position in the window. It will wrap lines as required.
* @note Uses the current foreground color to draw the string and fills the background using the background drawing color
*
* @param[in] gh The window handle (must be a console window)
* @param[in] str The string to draw
* @param[in] n The number of characters to draw
*
* @api
*/
void gwinPutCharArray(GHandle gh, const char *str, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* GWIN_NEED_CONSOLE */
#endif /* _GWIN_CONSOLE_H */
/** @} */

View File

@ -5,6 +5,24 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gwin/gwin.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Window Window
* @ingroup GWIN
*
* @details GWIN provides a basic window manager which allows it to easily
* create and destroy different windows on runtime. Each window
* will have it's own properties such as colors, brushes as well as
* it's own drawing origin.
* Moving the windows around is not supported yet.
*
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GWIN_H
#define _GWIN_H

View File

@ -4,30 +4,38 @@
*
* http://chibios-gfx.com/license.html
*/
#ifndef _GWIN_INTERNAL_H
#define _GWIN_INTERNAL_H
#if GFX_USE_GWIN || defined(__DOXYGEN__)
/*===========================================================================*/
/* Sub-system constants. */
/*===========================================================================*/
#define GWIN_FLG_DYNAMIC 0x0001
#define GBTN_FLG_ALLOCTXT 0x0002
#define GWIN_FIRST_CONTROL_FLAG 0x0004
#ifdef __cplusplus
extern "C" {
#endif
GHandle _gwinInit(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_t height, size_t size);
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_GWIN */
#endif /* _GWIN_INTERNAL_H */
/** @} */
/**
* @file include/gwin/internal.h
* @brief GWIN Graphic window subsystem header file.
*
* @addtogroup GWIN
* @{
*/
#ifndef _GWIN_INTERNAL_H
#define _GWIN_INTERNAL_H
#if GFX_USE_GWIN || defined(__DOXYGEN__)
/*===========================================================================*/
/* Sub-system constants. */
/*===========================================================================*/
#define GWIN_FLG_DYNAMIC 0x0001
#define GBTN_FLG_ALLOCTXT 0x0002
#define GWIN_FIRST_CONTROL_FLAG 0x0004
#ifdef __cplusplus
extern "C" {
#endif
GHandle _gwinInit(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_t height, size_t size);
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_GWIN */
#endif /* _GWIN_INTERNAL_H */
/** @} */

View File

@ -5,6 +5,20 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gwin/slider.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Slider Slider
* @ingroup GWIN
*
* @details Create sliders with different styles
*
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
* @pre GWIN_NEED_SLIDER must be set to TRUE in your gfxconf.h
* @{
*/
#ifndef _GWIN_SLIDER_H
#define _GWIN_SLIDER_H

View File

@ -5,6 +5,16 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file src/gwin/button.c
* @brief GWIN sub-system button code.
*
* @defgroup Button Button
* @ingroup GWIN
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"

View File

@ -4,133 +4,143 @@
*
* http://chibios-gfx.com/license.html
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GWIN && GWIN_NEED_CONSOLE) || defined(__DOXYGEN__)
#include <string.h>
#include "gwin/internal.h"
#define GWIN_CONSOLE_USE_CLEAR_LINES TRUE
#define GWIN_CONSOLE_USE_FILLED_CHARS FALSE
/*
* Stream interface implementation. The interface is write only
*/
#define Stream2GWindow(ip) ((GHandle)(((char *)(ip)) - (size_t)(&(((GConsoleObject *)0)->stream))))
static size_t GWinStreamWrite(void *ip, const uint8_t *bp, size_t n) { gwinPutCharArray(Stream2GWindow(ip), (const char *)bp, n); return RDY_OK; }
static size_t GWinStreamRead(void *ip, uint8_t *bp, size_t n) { (void)ip; (void)bp; (void)n; return 0; }
static msg_t GWinStreamPut(void *ip, uint8_t b) { gwinPutChar(Stream2GWindow(ip), (char)b); return RDY_OK; }
static msg_t GWinStreamGet(void *ip) {(void)ip; return RDY_OK; }
static msg_t GWinStreamPutTimed(void *ip, uint8_t b, systime_t time) { (void)time; gwinPutChar(Stream2GWindow(ip), (char)b); return RDY_OK; }
static msg_t GWinStreamGetTimed(void *ip, systime_t timeout) { (void)ip; (void)timeout; return RDY_OK; }
static size_t GWinStreamWriteTimed(void *ip, const uint8_t *bp, size_t n, systime_t time) { (void)time; gwinPutCharArray(Stream2GWindow(ip), (const char *)bp, n); return RDY_OK; }
static size_t GWinStreamReadTimed(void *ip, uint8_t *bp, size_t n, systime_t time) { (void)ip; (void)bp; (void)n; (void)time; return 0; }
struct GConsoleWindowVMT_t {
_base_asynchronous_channel_methods
};
static const struct GConsoleWindowVMT_t GWindowConsoleVMT = {
GWinStreamWrite,
GWinStreamRead,
GWinStreamPut,
GWinStreamGet,
GWinStreamPutTimed,
GWinStreamGetTimed,
GWinStreamWriteTimed,
GWinStreamReadTimed
};
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font) {
if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject))))
return 0;
gc->gwin.type = GW_CONSOLE;
gwinSetFont(&gc->gwin, font);
gc->stream.vmt = &GWindowConsoleVMT;
gc->cx = 0;
gc->cy = 0;
return (GHandle)gc;
}
BaseSequentialStream *gwinGetConsoleStream(GHandle gh) {
if (gh->type != GW_CONSOLE)
return 0;
return (BaseSequentialStream *)&(((GConsoleObject *)(gh))->stream);
}
void gwinPutChar(GHandle gh, char c) {
uint8_t width;
#define gcw ((GConsoleObject *)gh)
if (gh->type != GW_CONSOLE || !gh->font) return;
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
#endif
if (c == '\n') {
gcw->cx = 0;
gcw->cy += gcw->fy;
// We use lazy scrolling here and only scroll when the next char arrives
} else if (c == '\r') {
// gcw->cx = 0;
} else {
width = gdispGetCharWidth(c, gh->font) + gcw->fp;
if (gcw->cx + width >= gh->width) {
gcw->cx = 0;
gcw->cy += gcw->fy;
}
if (gcw->cy + gcw->fy > gh->height) {
#if GDISP_NEED_SCROLL
/* scroll the console */
gdispVerticalScroll(gh->x, gh->y, gh->width, gh->height, gcw->fy, gh->bgcolor);
/* reset the cursor to the start of the last line */
gcw->cx = 0;
gcw->cy = (((coord_t)(gh->height/gcw->fy))-1)*gcw->fy;
#else
/* clear the console */
gdispFillArea(gh->x, gh->y, gh->width, gh->height, gh->bgcolor);
/* reset the cursor to the top of the window */
gcw->cx = 0;
gcw->cy = 0;
#endif
}
#if GWIN_CONSOLE_USE_CLEAR_LINES
/* clear to the end of the line */
if (gcw->cx == 0)
gdispFillArea(gh->x, gh->y + gcw->cy, gh->width, gcw->fy, gh->bgcolor);
#endif
#if GWIN_CONSOLE_USE_FILLED_CHARS
gdispFillChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color, gh->bgcolor);
#else
gdispDrawChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color);
#endif
/* update cursor */
gcw->cx += width;
}
#undef gcw
}
void gwinPutString(GHandle gh, const char *str) {
while(*str)
gwinPutChar(gh, *str++);
}
void gwinPutCharArray(GHandle gh, const char *str, size_t n) {
while(n--)
gwinPutChar(gh, *str++);
}
#endif /* GFX_USE_GWIN && GWIN_NEED_CONSOLE */
/** @} */
/**
* @file src/gwin/console.c
* @brief GWIN sub-system console code.
*
* @defgroup Console Console
* @ingroup GWIN
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GWIN && GWIN_NEED_CONSOLE) || defined(__DOXYGEN__)
#include <string.h>
#include "gwin/internal.h"
#define GWIN_CONSOLE_USE_CLEAR_LINES TRUE
#define GWIN_CONSOLE_USE_FILLED_CHARS FALSE
/*
* Stream interface implementation. The interface is write only
*/
#define Stream2GWindow(ip) ((GHandle)(((char *)(ip)) - (size_t)(&(((GConsoleObject *)0)->stream))))
static size_t GWinStreamWrite(void *ip, const uint8_t *bp, size_t n) { gwinPutCharArray(Stream2GWindow(ip), (const char *)bp, n); return RDY_OK; }
static size_t GWinStreamRead(void *ip, uint8_t *bp, size_t n) { (void)ip; (void)bp; (void)n; return 0; }
static msg_t GWinStreamPut(void *ip, uint8_t b) { gwinPutChar(Stream2GWindow(ip), (char)b); return RDY_OK; }
static msg_t GWinStreamGet(void *ip) {(void)ip; return RDY_OK; }
static msg_t GWinStreamPutTimed(void *ip, uint8_t b, systime_t time) { (void)time; gwinPutChar(Stream2GWindow(ip), (char)b); return RDY_OK; }
static msg_t GWinStreamGetTimed(void *ip, systime_t timeout) { (void)ip; (void)timeout; return RDY_OK; }
static size_t GWinStreamWriteTimed(void *ip, const uint8_t *bp, size_t n, systime_t time) { (void)time; gwinPutCharArray(Stream2GWindow(ip), (const char *)bp, n); return RDY_OK; }
static size_t GWinStreamReadTimed(void *ip, uint8_t *bp, size_t n, systime_t time) { (void)ip; (void)bp; (void)n; (void)time; return 0; }
struct GConsoleWindowVMT_t {
_base_asynchronous_channel_methods
};
static const struct GConsoleWindowVMT_t GWindowConsoleVMT = {
GWinStreamWrite,
GWinStreamRead,
GWinStreamPut,
GWinStreamGet,
GWinStreamPutTimed,
GWinStreamGetTimed,
GWinStreamWriteTimed,
GWinStreamReadTimed
};
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font) {
if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject))))
return 0;
gc->gwin.type = GW_CONSOLE;
gwinSetFont(&gc->gwin, font);
gc->stream.vmt = &GWindowConsoleVMT;
gc->cx = 0;
gc->cy = 0;
return (GHandle)gc;
}
BaseSequentialStream *gwinGetConsoleStream(GHandle gh) {
if (gh->type != GW_CONSOLE)
return 0;
return (BaseSequentialStream *)&(((GConsoleObject *)(gh))->stream);
}
void gwinPutChar(GHandle gh, char c) {
uint8_t width;
#define gcw ((GConsoleObject *)gh)
if (gh->type != GW_CONSOLE || !gh->font) return;
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
#endif
if (c == '\n') {
gcw->cx = 0;
gcw->cy += gcw->fy;
// We use lazy scrolling here and only scroll when the next char arrives
} else if (c == '\r') {
// gcw->cx = 0;
} else {
width = gdispGetCharWidth(c, gh->font) + gcw->fp;
if (gcw->cx + width >= gh->width) {
gcw->cx = 0;
gcw->cy += gcw->fy;
}
if (gcw->cy + gcw->fy > gh->height) {
#if GDISP_NEED_SCROLL
/* scroll the console */
gdispVerticalScroll(gh->x, gh->y, gh->width, gh->height, gcw->fy, gh->bgcolor);
/* reset the cursor to the start of the last line */
gcw->cx = 0;
gcw->cy = (((coord_t)(gh->height/gcw->fy))-1)*gcw->fy;
#else
/* clear the console */
gdispFillArea(gh->x, gh->y, gh->width, gh->height, gh->bgcolor);
/* reset the cursor to the top of the window */
gcw->cx = 0;
gcw->cy = 0;
#endif
}
#if GWIN_CONSOLE_USE_CLEAR_LINES
/* clear to the end of the line */
if (gcw->cx == 0)
gdispFillArea(gh->x, gh->y + gcw->cy, gh->width, gcw->fy, gh->bgcolor);
#endif
#if GWIN_CONSOLE_USE_FILLED_CHARS
gdispFillChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color, gh->bgcolor);
#else
gdispDrawChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color);
#endif
/* update cursor */
gcw->cx += width;
}
#undef gcw
}
void gwinPutString(GHandle gh, const char *str) {
while(*str)
gwinPutChar(gh, *str++);
}
void gwinPutCharArray(GHandle gh, const char *str, size_t n) {
while(n--)
gwinPutChar(gh, *str++);
}
#endif /* GFX_USE_GWIN && GWIN_NEED_CONSOLE */
/** @} */

View File

@ -5,6 +5,16 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file src/gwin/graph.c
* @brief GWIN sub-system button code.
*
* @defgroup Graph Graph
* @ingroup GWIN
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"

View File

@ -5,6 +5,16 @@
* http://chibios-gfx.com/license.html
*/
/**
* @file src/gwin/slider.c
* @brief GWIN sub-system slider code.
*
* @defgroup Slider Slider
* @ingroup GWIN
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"