X-Git-Url: http://git.maemo.org/git/?p=mardrone;a=blobdiff_plain;f=mardrone%2FARDrone_SDK_Version_1_8_20110726%2FARDroneLib%2FVP_SDK%2FExamples%2Fnds%2Fatcodec_client.c;fp=mardrone%2FARDrone_SDK_Version_1_8_20110726%2FARDroneLib%2FVP_SDK%2FExamples%2Fnds%2Fatcodec_client.c;h=deea953555f4b502f61ec9d25fa439e514aa0362;hp=0000000000000000000000000000000000000000;hb=9ec9bc13b75d30bc45535c54a652934debfcea92;hpb=ae0a3c2dc0898400aca0dd6b439c5db8044db7b2 diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VP_SDK/Examples/nds/atcodec_client.c b/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VP_SDK/Examples/nds/atcodec_client.c new file mode 100644 index 0000000..deea953 --- /dev/null +++ b/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VP_SDK/Examples/nds/atcodec_client.c @@ -0,0 +1,136 @@ + +#include +#include + +#include +#include + +#define AT_MESSAGES_HEADER "ATcodec/ATcodec_Messages_ex.h" + +#include "ATcodec/ATcodec_api.h" +#include "VP_Os/vp_os_types.h" +#include "VP_Os/vp_os_thread.h" +#include "VP_Os/vp_os_delay.h" +#include "VP_Os/vp_os_print.h" +#include + +#include + +#ifndef AT_MESSAGES_HEADER +#error You need to define AT_MESSAGES_HEADER +#endif + +extern AT_CODEC_MSG_IDS ids; + +#define INTRA_CMD_DELAY 10 + + +volatile int frame = 0; + + +//--------------------------------------------------------------------------------- +void Vblank() +{ + //--------------------------------------------------------------------------------- + frame++; +} + + +//--------------------------------------------------------------------------------- +void initNDS() +{ + //--------------------------------------------------------------------------------- + irqInit(); + irqSet(IRQ_VBLANK, Vblank); + irqEnable(IRQ_VBLANK); + videoSetMode(0); //not using the main screen + videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + vramSetBankC(VRAM_C_SUB_BG); + + SUB_BG0_CR = BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] = RGB15(31,31,31); //by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); +} + + +//--------------------------------------------------------------------------------- +THREAD_RET +thread_send_commands (THREAD_PARAMS data) +{ + //--------------------------------------------------------------------------------- + while(1) + { + ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_CGMI); + vp_os_delay(INTRA_CMD_DELAY); + ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_CGMI); + vp_os_delay(INTRA_CMD_DELAY); + //vp_os_thread_yield(); + + ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_PM_QW,1); + vp_os_delay(INTRA_CMD_DELAY); + ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_PM_QW,1); + vp_os_delay(INTRA_CMD_DELAY); + //vp_os_thread_yield(); + + ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_PM_EXE,1,50); + vp_os_delay(INTRA_CMD_DELAY); + ATcodec_Queue_Message_valist(ids.AT_MSG_ATCMD_PM_EXE,1,50); + vp_os_delay(INTRA_CMD_DELAY); + //vp_os_thread_yield(); + } +} + + +//--------------------------------------------------------------------------------- +int main(int argc, char **argv) +{ + //--------------------------------------------------------------------------------- + touchPosition touchXY; + THREAD_HANDLE atcodec_test_handle; + THREAD_HANDLE atcodec_test_handle2; + THREAD_HANDLE cmds_handle; + + initNDS(); + + AT_CODEC_FUNCTIONS_PTRS ptrs = + { + .init = AT_CODEC_Client_init, + .shutdown = AT_CODEC_Client_shutdown, + .open = AT_CODEC_Client_open, + .close = AT_CODEC_Client_close, + .read = AT_CODEC_Client_read, + .write = AT_CODEC_Client_write, + }; + + ATcodec_Init_Library(&ptrs); + + vp_os_thread_create(thread_ATcodec_Commands_Client, 0, &atcodec_test_handle); + vp_os_thread_create(thread_send_commands, 0, &cmds_handle); + vp_os_thread_create(thread_ATcodec_Commands_Server, 0, &atcodec_test_handle2); + + vp_os_thread_join(cmds_handle); + vp_os_thread_join(atcodec_test_handle2); + vp_os_thread_join(atcodec_test_handle); + + iprintf(" Hello DS dev'rs\n"); + iprintf(" www.devkitpro.org\n"); + iprintf(" www.drunkencoders.com"); + + while(1) { + + swiWaitForVBlank(); + touchXY=touchReadXY(); + + // print at using ansi escape sequence \x1b[line;columnH + iprintf("\x1b[10;0HFrame = %d",frame); + iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.x, touchXY.px); + iprintf("Touch y = %04X, %04X\n", touchXY.y, touchXY.py); + + } + + return EXIT_SUCCESS; +} +