Added service function. (A service function dumping information for debugging, Added service function for screen drawing ON / OFF control) Specifically, see README. Make the object's destructor called from bios_exit () Add appropriate Destroy function to each object. Delete objects properly We have checked the termination process as a whole, as done. Fix to accept interrupts even during key_wait (). (Previously, only key input was accepted) Some timer interrupts are improved. (UNIXTimer.c) Change the wonx_include directory to wonx. Changed to search the full path to perl automatically and insert it at the beginning of perl script. Makefile review, improvement. Changed ON / OFF of screen drawing to switch according to display level. (See README for details.) Also change to display level lowered by F9 and display level raised by F10. In accordance with that, we have reviewed a part of ON / OFF part of drawing and key input event processing. Fixed to display message when pressing key. Obj ObjListData_GetPrev (ObjListData data) Obj ObjListData_GetNext (ObjListData data) To ObjListData ObjListData_GetPrev (ObjListData data) ObjListData ObjListData_GetNext (ObjListData data) Fixed to. Added install, uninstall target to Makefile. Fixed challsrc.sh. Version 2.2 - from wonx-2.2.tar.gz
127 lines
3.7 KiB
C
127 lines
3.7 KiB
C
#include "WonXP.h"
|
||
#include "etc.h"
|
||
|
||
#include "wonx/disp.h"
|
||
#include "wonx/system.h"
|
||
#include "wonx/comm.h"
|
||
|
||
static WonX wonx = NULL;
|
||
|
||
int WonX_IsCreated(void)
|
||
{
|
||
return (wonx != NULL);
|
||
}
|
||
|
||
void WonX_Create(void)
|
||
{
|
||
if (WonX_IsCreated())
|
||
WonX_Error("WonX_Create", "WonX has been already created.");
|
||
|
||
wonx = (WonX)malloc(sizeof(_WonX));
|
||
if (wonx == NULL) WonX_Error("WonX_Create", "Cannot allocate memory.");
|
||
|
||
/*
|
||
* WonX のタイマからはディスプレイのリフレッシュなどの関数を呼び出すため,
|
||
* WonXSystem_Create() でタイマをスタートさせる前に WonXDisplay_Create() で
|
||
* WonXDisplay オブジェクトを作成しておく必要がある.このため
|
||
* WonXDisplay_Create() を WonXSystem_Create() の後に持っていってはいけない.
|
||
*/
|
||
wonx->wonx_display =
|
||
WonXDisplay_Create(LCD_PIXEL_WIDTH * 2, LCD_PIXEL_HEIGHT * 2,
|
||
LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT,
|
||
SCREEN_CHAR_WIDTH, SCREEN_CHAR_HEIGHT);
|
||
|
||
/*
|
||
* WonXDisplay と同様のことが WonXSerialPort でも将来的に起きる可能性が
|
||
* あるかもしれないので, WonXSerialPort_Create() もいちおう
|
||
* WonXSystem_Create() の前に置いておく.
|
||
*/
|
||
wonx->wonx_serial_port = WonXSerialPort_Create();
|
||
|
||
/*
|
||
* WonXSystem_Create() ではタイマを作成するが,タイマからはいろいろな
|
||
* オブジェクトが呼ばれる可能性があるため,タイマの作成は一番最後に行う
|
||
* べきである.このため,WonXSystem_Create() は一番最後に行う.
|
||
* (他のオブジェクトの作成中等にタイマがかかった場合,おかしなことに
|
||
* なってしまう)
|
||
*/
|
||
wonx->wonx_system = WonXSystem_Create();
|
||
|
||
return;
|
||
}
|
||
|
||
void WonX_Destroy(void)
|
||
{
|
||
if (!WonX_IsCreated())
|
||
WonX_Error("WonX_Destroy", "WonX has not been created yet.");
|
||
|
||
/*
|
||
* WonXSystem はタイマを持つが,タイマからはいろいろなオブジェクトが
|
||
* 呼ばれる可能性があるため,一番最初にタイマを停止する必要がある.
|
||
* このため,WonXSystem_Destroy() は一番最初に行う.
|
||
* (他のオブジェクトの削除中等にタイマがかかった場合,おかしなことに
|
||
* なってしまう)
|
||
*/
|
||
if (wonx->wonx_system)
|
||
wonx->wonx_system = WonXSystem_Destroy(wonx->wonx_system);
|
||
|
||
/*
|
||
* WonXDisplay と同様のことが WonXSerialPort でも将来的に起きる可能性が
|
||
* あるかもしれないので, WonXSerialPort_Destroy() もいちおう
|
||
* WonXSystem_Destroy() の後に置いておく.
|
||
*/
|
||
if (wonx->wonx_serial_port)
|
||
wonx->wonx_serial_port = WonXSerialPort_Destroy(wonx->wonx_serial_port);
|
||
|
||
/*
|
||
* WonX のタイマからはディスプレイのリフレッシュなどの関数を呼び出すため,
|
||
* WonXDisplay を消去する前に WonXSystem を消去して,タイマを停止する
|
||
* 必要がある.(でないと WonXDisplay_Destroy() の実行中にタイマがかかった
|
||
* ときに,おかしなことになる)
|
||
* このため,WonXDisplay_Destroy() を WonXSystem_Destroy() の前に
|
||
* 持っていってはいけない.
|
||
*/
|
||
if (wonx->wonx_display)
|
||
wonx->wonx_display = WonXDisplay_Destroy(wonx->wonx_display);
|
||
|
||
free(wonx);
|
||
wonx = NULL;
|
||
|
||
return;
|
||
}
|
||
|
||
WonXDisplay WonX_GetWonXDisplay(void)
|
||
{
|
||
return (wonx->wonx_display);
|
||
}
|
||
|
||
WonXSystem WonX_GetWonXSystem(void)
|
||
{
|
||
return (wonx->wonx_system);
|
||
}
|
||
|
||
WonXSerialPort WonX_GetWonXSerialPort(void)
|
||
{
|
||
return (wonx->wonx_serial_port);
|
||
}
|
||
|
||
/*===========================================================================*/
|
||
/* エラー処理 */
|
||
/*===========================================================================*/
|
||
|
||
int WonX_Error(char * funcname, char * message)
|
||
{
|
||
fprintf(stderr, "error : %s(): %s\n", funcname, message);
|
||
exit (1);
|
||
}
|
||
|
||
int WonX_Warning(char * funcname, char * message)
|
||
{
|
||
fprintf(stderr, "warning : %s(): %s\n", funcname, message);
|
||
return (0);
|
||
}
|
||
|
||
/*****************************************************************************/
|
||
/* End of File. */
|
||
/*****************************************************************************/
|