├── RePhone_Create_Source_Code ├── ARM │ ├── cjson.o │ ├── ifttt.o │ ├── main.o │ ├── music.o │ ├── ugui.o │ ├── util.o │ ├── action.o │ ├── actuator.o │ ├── battery.o │ ├── call_ui.o │ ├── gccmain.o │ ├── gui_glue.o │ ├── ifttt_ui.o │ ├── laudio.o │ ├── ldlceint.o │ ├── ldlcgpio.o │ ├── lgsmsms.o │ ├── lmotor.o │ ├── lstorage.o │ ├── sensor.o │ ├── settings.o │ ├── sms_book.o │ ├── sms_ui.o │ ├── tp_i2c.o │ ├── windows.o │ ├── condition.o │ ├── contact_ui.o │ ├── font_ugui.o │ ├── ifttt_book.o │ ├── ldlci2cV2.o │ ├── lledmatrix.o │ ├── lrgbws2812.o │ ├── lvoicecall.o │ ├── address_book.o │ ├── font_icon24.o │ ├── font_icon48.o │ ├── input_window.o │ ├── ws2812_window.o │ ├── tp_goodix_gt9xx.o │ ├── vibrator_window.o │ ├── led_matrix_window.o │ ├── lcd_sitronix_st7789s.o │ ├── RePhone_Create_Source_Code.res │ └── RePhone_Create_Source_Code_default.vxp ├── res │ ├── RePhone_Create_Source_Code.res.xml │ └── ref_list_RePhone_Create_Source_Code.txt ├── battery.h ├── .project ├── readme.txt ├── lstorage.h ├── sms_book.h ├── battery.c ├── ldlcgpio.h ├── action.h ├── actuator.h ├── lmotor.h ├── ResID │ └── ResID.h ├── ifttt.h ├── ifttt_book.h ├── lvoicecall.h ├── address_book.h ├── util.c ├── lgsmsms.h ├── laudio.h ├── custom_config.xml ├── lrgbws2812.h ├── condition.h ├── ldlci2cV2.h ├── ldlceint.h ├── lmotor.c ├── lledmatrix.h ├── sensor.h ├── tp_i2c.h ├── ugui_config.h ├── actuator.c ├── action.c ├── config.xml ├── sms_book.c ├── lrgbws2812.c ├── lledmatrix.c ├── address_book.c ├── vibrator_window.c ├── input_window.c ├── condition.c ├── sensor.c ├── laudio.c ├── tp_goodix_gt9xx.h ├── lstorage.c ├── music.c ├── ldlci2cV2.c ├── ldlcgpio.c ├── ifttt.c ├── gui_glue.c ├── lvoicecall.c ├── main.c ├── RePhone_Create_Source_Code.proj ├── cjson.h ├── led_matrix_window.c ├── ldlceint.c ├── lcd_sitronix_st7789s.h ├── settings.c ├── call_ui.c ├── lgsmsms.c ├── contact_ui.c └── .cproject ├── readme.txt ├── .gitattributes └── .gitignore /RePhone_Create_Source_Code/ARM/cjson.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/cjson.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/ifttt.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/ifttt.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/main.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/music.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/music.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/ugui.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/ugui.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/util.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/util.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/action.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/action.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/actuator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/actuator.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/battery.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/battery.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/call_ui.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/call_ui.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/gccmain.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/gccmain.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/gui_glue.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/gui_glue.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/ifttt_ui.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/ifttt_ui.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/laudio.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/laudio.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/ldlceint.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/ldlceint.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/ldlcgpio.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/ldlcgpio.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/lgsmsms.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/lgsmsms.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/lmotor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/lmotor.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/lstorage.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/lstorage.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/sensor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/sensor.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/settings.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/settings.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/sms_book.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/sms_book.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/sms_ui.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/sms_ui.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/tp_i2c.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/tp_i2c.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/windows.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/windows.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/condition.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/condition.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/contact_ui.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/contact_ui.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/font_ugui.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/font_ugui.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/ifttt_book.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/ifttt_book.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/ldlci2cV2.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/ldlci2cV2.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/lledmatrix.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/lledmatrix.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/lrgbws2812.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/lrgbws2812.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/lvoicecall.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/lvoicecall.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/address_book.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/address_book.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/font_icon24.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/font_icon24.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/font_icon48.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/font_icon48.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/input_window.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/input_window.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/ws2812_window.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/ws2812_window.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/tp_goodix_gt9xx.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/tp_goodix_gt9xx.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/vibrator_window.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/vibrator_window.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/led_matrix_window.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/led_matrix_window.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/lcd_sitronix_st7789s.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/lcd_sitronix_st7789s.o -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/res/RePhone_Create_Source_Code.res.xml: -------------------------------------------------------------------------------- 1 | 2 | .\res\ref_list_RePhone_Create_Source_Code.txt 3 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/RePhone_Create_Source_Code.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/RePhone_Create_Source_Code.res -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ARM/RePhone_Create_Source_Code_default.vxp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/ARM/RePhone_Create_Source_Code_default.vxp -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/res/ref_list_RePhone_Create_Source_Code.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WayenWeng/RePhone_Create_Kit_Source_Code/HEAD/RePhone_Create_Source_Code/res/ref_list_RePhone_Create_Source_Code.txt -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/battery.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __BATTERY_H__ 4 | #define __BATTERY_H__ 5 | 6 | 7 | int battery_is_level(); 8 | int battery_is_charging(); 9 | 10 | 11 | #endif // __BATTERY_H__ 12 | 13 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RePhone_Create_Source_Code 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | 1. RePhone_Create_Source_Code 2 | - IDE Eclipse 3 | - RePhone Create Kit source code 4 | 5 | 2. These is a define in file "lcd_sitronix_st7789s.h", and need to sure the version of Xadow 1.54" Touchscreen. 6 | If the version is v1.0 choose "_TOUCH_SCREEN_V1_0_", else if the version is v1.1 choose "_TOUCH_SCREEN_V1_1_". -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/readme.txt: -------------------------------------------------------------------------------- 1 | This example shows how to receive touch event and the x,y value from the board. 2 | 3 | This example uses vm_touch_register_event_callback() to register touch handler. 4 | When touch the LCD on the board, the touch event and (x,y) value will be sent to application to touch handler. 5 | 6 | Just run this application, and observe monitor log. 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lstorage.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _LSTORAGE_H 3 | #define _LSTORAGE_H 4 | 5 | 6 | void file_create(const char* fileName); 7 | void file_open(const char* fileName); 8 | void file_write(const char* fileName, const char* strBuf, long pos); 9 | void file_delete(const char* fileName); 10 | void file_read(const char* fileName, char* strBuf, unsigned int nByte, long pos); 11 | void file_size(const char* fileName, unsigned long* size); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/sms_book.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SMS_BOOK_H 3 | #define _SMS_BOOK_H 4 | 5 | 6 | #define ADDRESS_MAX 20 7 | #define CONTENT_LEN_MAX 151 8 | 9 | 10 | void sms_book_open(); 11 | void sms_book_add(char* content); 12 | int sms_book_find(char* content); 13 | void sms_book_delete(char* content); 14 | void sms_save(); 15 | int sms_get_max_item_num(); 16 | const char* sms_get_item(unsigned int num); 17 | void sms_book_show(); 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/battery.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "battery.h" 4 | #include "ldlcgpio.h" 5 | 6 | int battery_get_level() 7 | { 8 | // int level = vm_pwr_get_battery_level(); 9 | int level = analogRead(0); 10 | if (level < 840) { 11 | level = 840; 12 | } 13 | return (level - 840) * 100 / (1023 - 840); 14 | } 15 | 16 | int battery_is_charging() 17 | { 18 | if (vm_pwr_is_charging()) 19 | return 1; 20 | else 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ldlcgpio.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _LDLCGPIO_H 3 | #define _LDLCGPIO_H 4 | 5 | #include "vmtype.h" 6 | 7 | #define HIGH 0x1 8 | #define LOW 0x0 9 | 10 | #define INPUT 0x0 11 | #define OUTPUT 0x1 12 | #define INPUT_PULLUP 0x2 13 | #define INPUT_PULLDN 0x3 14 | 15 | 16 | VMINT8 pinMode(VMUINT8 ulPin,VMUINT8 ulMode); 17 | VMINT8 digitalWrite(VMUINT8 ulPin,VMUINT8 ulData); 18 | VMINT8 digitalRead(VMUINT8 ulPin); 19 | VMINT32 analogRead(VMUINT8 ulPin); 20 | 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/action.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ACTION_H__ 3 | #define __ACTION_H__ 4 | 5 | #include 6 | 7 | #define ACTION_MAX_NUMBER 32 8 | 9 | typedef int (*action_pfunc_t)(void *); 10 | 11 | int action_add(action_pfunc_t pfunc); 12 | void action_remove(int action_id); 13 | int action_exec(int action_id); 14 | void action_set_function(int index, int (*pfunc)(void *)); 15 | uint32_t *action_get_data(int index); 16 | char *action_to_string(int index, char *pbuf, int len); 17 | 18 | #endif // __ACTION_H__ 19 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/actuator.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ACTUATOR_H__ 3 | #define __ACTUATOR_H__ 4 | 5 | #include "action.h" 6 | 7 | #define ACTUATOR_MAX_NUMBER 16 8 | #define ACTUATOR_HIDDEN_NUMBER 2 9 | 10 | typedef void (*actuator_pfunc_t)(uint32_t *pdata); 11 | 12 | int actuator_get_number(); 13 | char *actuator_get_name(int index); 14 | action_pfunc_t actuator_get_action_function(int index); 15 | int actuator_get_action_data(int index, uint32_t *pdata); 16 | char *actuator_get_action_name(actuator_pfunc_t pfunc); 17 | 18 | #endif // __ACTUATOR_H__ 19 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lmotor.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _LMOTOR_H 4 | #define _LMOTOR_H 5 | 6 | 7 | #include "stdint.h" 8 | 9 | 10 | #define MOTOR_Address 34 11 | 12 | #define MOTOR_SET_WORK 0x80 13 | #define MOTOR_SET_MODE 0x81 14 | 15 | #define MOTOR_MODE_SHORT 0x00 16 | #define MOTOR_MODE_LONG 0x01 17 | #define MOTOR_MODE_INTERVAL 0x02 18 | 19 | 20 | uint8_t motor_check_on_line(); 21 | void motor_set_work(uint16_t uiTime); 22 | void motor_set_mode(uint8_t ucMode); 23 | void motor_do_action(uint32_t *pdata); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ResID/ResID.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Filename: 3 | * --------- 4 | * ResID\ResID.h : header file 5 | * 6 | * Description: 7 | * ------------ 8 | * 9 | * 10 | * This is auto generated by ResEditor.exe 11 | **************************************************************************/ 12 | 13 | #if !defined _RESID_RESID_H_ 14 | #define _RESID_RESID_H_ 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif /* _RESID_RESID_H_ */ 27 | 28 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ifttt.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __IFTTT_H__ 3 | #define __IFTTT_H__ 4 | 5 | #include 6 | 7 | #define IFTTT_MAX_NUMBER 16 8 | 9 | struct _ifttt_t { 10 | struct _ifttt_t *prev; 11 | uint32_t condition_mask; 12 | uint32_t action_mask; 13 | uint8_t last; 14 | char name[32]; 15 | }; 16 | 17 | typedef struct _ifttt_t ifttt_t; 18 | 19 | void ifttt_check(); 20 | int ifttt_add(int8_t *condition_index_map, int8_t *action_index_map); 21 | void ifttt_remove(int index); 22 | int ifttt_get_number(); 23 | char *ifttt_get_name(int index); 24 | char *ifttt_get_description(int index); 25 | ifttt_t *ifttt_get(int index); 26 | 27 | #endif // __IFTTT_H__ 28 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ifttt_book.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _IFTTT_BOOK_H 3 | #define _IFTTT_BOOK_H 4 | 5 | 6 | #define IF_NAME_MAX 10 7 | #define THEN_NAME_MAX 5 8 | #define IF_SHORT_NAME_MAX 8 9 | #define THEN_SHORT_NAME_MAX 7 10 | 11 | 12 | extern void led_matrix_do_action(unsigned long *pdata); 13 | extern void rgb_ws2812_do_action(unsigned long *pdata); 14 | extern void music_do_action(unsigned long *pdata); 15 | extern void motor_do_action(unsigned long *pdata); 16 | extern void call_do_action(unsigned long *pdata); 17 | extern void sms_do_action(unsigned long *pdata); 18 | 19 | 20 | void ifttt_book_open(); 21 | void ifttt_book_save(); 22 | void ifttt_book_show(); 23 | void ifttt_book_add(char *content); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lvoicecall.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _LVOICECALL_H 4 | #define _LVOICECALL_H 5 | 6 | #include "vmgsm_tel.h" 7 | 8 | enum VoiceCall_Status 9 | { 10 | IDLE_CALL, 11 | CALLING, 12 | RECEIVINGCALL, 13 | TALKING 14 | }; 15 | 16 | typedef struct 17 | { 18 | VMINT result; 19 | VMINT8 num[42]; 20 | }call_info_struct; 21 | 22 | 23 | VMUINT8 callvoiceCall(void* user_data); 24 | VMUINT8 callanswerCall(void* user_data); 25 | VMUINT8 callhangCall(void* user_data); 26 | 27 | void callretrieveCallingNumber(void* user_data); 28 | void callgetVoiceCallStatus(void* user_data); 29 | 30 | void callregisterCallback(void (*call_state_changed_callback)(VMINT8)); 31 | 32 | void call_listener_func(vm_gsm_tel_call_listener_data_t* data); 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/address_book.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _ADDRESS_BOOK_H 3 | #define _ADDRESS_BOOK_H 4 | 5 | 6 | #define ADDRESS_MAX 20 7 | #define NAME_LEN_MAX 24 8 | #define NUM_LEN_MAX 16 9 | 10 | 11 | void book_open(); // get data from flash 12 | void book_add(char* name, char* num); 13 | int book_find(char* name); // return item num, find nothing return -1 14 | void book_delete(char* name); // delete a certain item 15 | void book_show(); 16 | void book_save(); 17 | int book_get_number(); 18 | void book_get_item(unsigned int num, char *buf, unsigned int len); 19 | const char* book_get_item_name(unsigned int num); 20 | const char* book_get_item_number(unsigned int num); 21 | 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/util.c: -------------------------------------------------------------------------------- 1 | 2 | char *itoa(int num, char *str, int radix) 3 | { 4 | char index[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 5 | unsigned unum; 6 | int i = 0, j, k; 7 | if (radix == 10 && num < 0) { 8 | unum = (unsigned) -num; 9 | str[i++] = '-'; 10 | } else 11 | unum = (unsigned) num; 12 | 13 | do { 14 | str[i++] = index[unum % (unsigned) radix]; 15 | unum /= radix; 16 | } while (unum); 17 | str[i] = '\0'; 18 | 19 | if (str[0] == '-') 20 | k = 1; 21 | else 22 | k = 0; 23 | char temp; 24 | for (j = k; j <= (i - 1) / 2; j++) { 25 | temp = str[j]; 26 | str[j] = str[i - 1 + k - j]; 27 | str[i - 1 + k - j] = temp; 28 | } 29 | return str; 30 | } 31 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lgsmsms.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _LGSMSMS_H 3 | #define _LGSMSMS_H 4 | 5 | 6 | #define GSM_SMS_NUM_MAX 20 7 | 8 | 9 | typedef struct 10 | { 11 | char number[42]; 12 | char content[151]; 13 | int result; 14 | }sms_send_struct; 15 | 16 | typedef struct 17 | { 18 | int id; 19 | char *number; 20 | char *content; 21 | }sms_unread_msg_struct; 22 | 23 | 24 | void gsm_sms_set_interrupt_event_handler(void); 25 | 26 | VMUINT8 gsm_sms_ready(void); 27 | VMUINT8 gsm_sms_begin(void* userdata); 28 | VMUINT8 gsm_sms_send(void* userdata); 29 | 30 | VMUINT16 gsm_sms_get_list_number(void); 31 | char* gsm_sms_remote_number(VMUINT8 num); 32 | char* gsm_sms_remote_content(VMUINT8 num); 33 | void gsm_sms_set_new_message_callback(void (*cb)(char *, char *)); 34 | void gsm_sms_set_send_message_callback(void (*cb)(int)); 35 | 36 | void sms_inbox_show(); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/laudio.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _LAUDIO_H 4 | #define _LAUDIO_H 5 | 6 | 7 | typedef enum 8 | { 9 | AudioCommonFailed = -1, // Playback fails (e.g. the audio file is corrupted). 10 | AudioStop = 1, // Playback is stopped. 11 | AudioPause = 7, // Playback is paused (and can resume). 12 | AudioResume = 8, // Playback resumes 13 | AudioEndOfFile = 5 // Playback is finished. 14 | }AudioStatus; 15 | 16 | // storage location 17 | typedef enum 18 | { 19 | storageFlash, // Flash 20 | storageSD // SD 21 | }StorageEnum; 22 | 23 | 24 | VMUINT8 audioPlay(StorageEnum drv, VMINT8 *songName); 25 | VMUINT8 audioPause(void* user_data); 26 | VMUINT8 audioResume(void* user_data); 27 | VMUINT8 audioSetVolume(VMUINT8 volData); 28 | VMUINT8 audioStop(void* user_data); 29 | VMINT8 audioGetStatus(void* user_data); 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/custom_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MediaTek Inc 5 | Demo 6 | 2.0.0 7 | -1 8 | 9 | 10 | 800 11 | 12 | 13 | 2 14 | 15 | 16 | -mthumb-interwork -c -gdwarf-2 -gstrict-dwarf -fpic -mcpu=arm7tdmi-s -fvisibility=hidden -mthumb -mlittle-endian -O2 -D__COMPILER_GCC__ -fno-exceptions -fno-non-call-exceptions 17 | -fno-rtti -mthumb-interwork -c -gdwarf-2 -gstrict-dwarf -fpic -mcpu=arm7tdmi-s -fvisibility=hidden -mthumb -mlittle-endian -O2 -D__COMPILER_GCC__ -fno-exceptions -fno-non-call-exceptions 18 | -Wl,--gc-sections -fpic -pie --specs=nosys.specs -lm 19 | 20 | 21 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lrgbws2812.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _LRGBWS2812_H 4 | #define _LRGBWS2812_H 5 | 6 | 7 | #include "stdint.h" 8 | 9 | 10 | #define RGB_WS2812_Address 35 11 | 12 | #define RGB_SET_WORK 0x80 13 | #define RGB_SET_MODE 0x81 14 | 15 | #define RGB_POWER_OFF 0 16 | #define RGB_POWER_ON 1 17 | #define RGB_MONOCHROME 2 18 | #define RGB_MARQUEE 3 19 | #define RGB_RAINBOW 4 20 | 21 | 22 | void rgb_ws2812_power_off(); 23 | void rgb_ws2812_power_on(); 24 | uint8_t rgb_ws2812_check_on_line(); 25 | void rgb_ws2812_set_pixel_color(uint32_t ulRGB, uint8_t ucNum); 26 | void rgb_ws2812_monochrome(uint8_t ucNum, uint32_t ulRGBData, uint16_t uiTime); 27 | void rgb_ws2812_marquee(uint8_t ucNum, uint32_t ulRGBData, uint16_t uiTime); 28 | void rgb_ws2812_rainbow(uint8_t ucNum, uint16_t uiTime); 29 | void rgb_ws2812_do_action(uint32_t *pdata); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/condition.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CONDITION_H__ 3 | #define __CONDITION_H__ 4 | 5 | #include "sensor.h" 6 | 7 | #include 8 | 9 | #define CONDITION_MAX_NUMBER 32 10 | 11 | 12 | typedef struct { 13 | uint8_t type; 14 | uint8_t op; 15 | uint16_t id; 16 | union { 17 | uint32_t u32; 18 | int32_t i32; 19 | float f32; 20 | void *p; 21 | }; 22 | } condition_t; 23 | 24 | extern condition_t g_condition_list[CONDITION_MAX_NUMBER]; 25 | 26 | int condition_add(sensor_t *sensor); 27 | int condition_check(int index); 28 | condition_t *condition_get(int index); 29 | void condition_remove(int index); 30 | void condition_set_value(int index, char *str); 31 | void *condition_get_value(int index); 32 | void condition_set_operator(int index, uint8_t op); 33 | char *condition_to_string(int index, char *pbuf, int len); 34 | 35 | #endif // __CONDITION_H__ 36 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ldlci2cV2.h: -------------------------------------------------------------------------------- 1 | #ifndef _LDLCI2CV2_H 2 | #define _LDLCI2CV2_H 3 | 4 | #include "vmtype.h" 5 | 6 | 7 | //configure HW I2C parameters 8 | void dlc_i2c_configure(VMUINT32 slave_addr, VMUINT32 speed); 9 | 10 | // Send one byte from host to client 11 | VMUINT8 dlc_i2c_send_byte(VMUINT8 ucData); 12 | 13 | // Receive one byte form client to host 14 | VMUINT8 dlc_i2c_receive_byte(VMUINT8 bAck); 15 | 16 | // I2C send data fuction 17 | VMUINT8 dlc_i2c_send(VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 18 | 19 | // I2C receive data function 20 | VMUINT8 dlc_i2c_receive(VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 21 | 22 | // I2C send data for 16 bits address fuction 23 | VMUINT8 dlc_i2c_send_ext(VMUINT16 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 24 | 25 | // I2C receive data for 16 bits address function 26 | VMUINT8 dlc_i2c_receive_ext(VMUINT16 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 27 | 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ldlceint.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _LDLCEINT_H 3 | #define _LDLCEINT_H 4 | 5 | #include "vmdcl.h" 6 | 7 | //#define LOW 0 8 | //#define HIGH 1 9 | #define FALLING 2 10 | #define RISING 3 11 | #define CHANGE 4 12 | 13 | 14 | typedef void (*voidFuncPtr)( void ) ; 15 | 16 | 17 | typedef enum _EExt_Interrupts 18 | { 19 | EXTERNAL_INT_0=0,// 20 | EXTERNAL_INT_1=1,// 21 | EXTERNAL_INT_2=2,// 22 | EXTERNAL_INT_3=3,// 23 | EXTERNAL_INT_4=4,// 24 | EXTERNAL_INT_5=5,// 25 | EXTERNAL_INT_6=6,// 26 | EXTERNAL_INT_7=7,// 27 | EXTERNAL_INT_8=8,// 28 | EXTERNAL_INT_9=9,// 29 | EXTERNAL_NUM_INTERRUPTS 30 | }EExt_Interrupts; 31 | 32 | 33 | typedef struct _Exinterrupts_Struct 34 | { 35 | VM_DCL_HANDLE handle; 36 | VMUINT32 pin; 37 | VMUINT32 eint; 38 | VMUINT32 first; 39 | voidFuncPtr cb; 40 | }Exinterrupts_Struct; 41 | 42 | 43 | typedef void (*callback_ptr)(void); 44 | void attachInterrupt(VMUINT32 pin, callback_ptr callback, VMUINT32 mode); 45 | void detachInterrupt(VMUINT32 pin); 46 | void interrupts(void); 47 | void noInterrupts(void ); 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lmotor.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmtype.h" 3 | #include "vmlog.h" 4 | #include "ldlci2cV2.h" 5 | #include "lmotor.h" 6 | 7 | uint8_t motor_check_on_line() 8 | { 9 | uint8_t DataBuf[4] = {0}; 10 | 11 | dlc_i2c_configure(MOTOR_Address, 100); 12 | dlc_i2c_receive(0, DataBuf, 4); 13 | 14 | vm_log_info("motor check data is %x %x %x %x",DataBuf[0],DataBuf[1],DataBuf[2],DataBuf[3]); 15 | 16 | if(DataBuf[3] == MOTOR_Address) 17 | { 18 | vm_log_info("motor is on line."); 19 | return TRUE; 20 | } 21 | else 22 | { 23 | vm_log_info("motor is not on line."); 24 | return FALSE; 25 | } 26 | } 27 | 28 | void motor_set_work(uint16_t uiTime) 29 | { 30 | uint8_t DataBuf[2] = {0}; 31 | 32 | DataBuf[0] = ((uiTime >> 8) & 0xff); 33 | DataBuf[1] = (uiTime & 0xff); 34 | 35 | dlc_i2c_configure(MOTOR_Address, 100); 36 | dlc_i2c_send(MOTOR_SET_WORK, DataBuf, 2); 37 | } 38 | 39 | void motor_set_mode(uint8_t ucMode) 40 | { 41 | dlc_i2c_configure(MOTOR_Address, 100); 42 | dlc_i2c_send(MOTOR_SET_MODE, &ucMode, 1); 43 | } 44 | 45 | void motor_do_action(uint32_t *pdata) 46 | { 47 | motor_set_work(pdata[0]); 48 | } 49 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lledmatrix.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _LLEDMATRIX_H 4 | #define _LLEDMATRIX_H 5 | 6 | #include "vmtype.h" 7 | 8 | #define LEDAddress 33 9 | 10 | #define DISP_CHAR_5X7 0x80 11 | #define DISP_STRING 0x81 12 | #define SET_DISP_ORIENTATION 0x82 13 | #define POWER_DOWN 0x83 14 | #define DISP_PIC 0x84 15 | 16 | #define RIGHT_TO_LEFT 0 17 | #define LEFT_TO_RIGHT 1 18 | 19 | #define DIS_PIC_JOY_LVL0 0 // Joy level 0 20 | #define DIS_PIC_JOY_LVL1 1 // Joy level 1 21 | #define DIS_PIC_SAD_LVL0 2 // Sad level 0 22 | #define DIS_PIC_SAD_LVL1 3 // Sad level 1 23 | #define DIS_PIC_SAD_LVL2 4 // Sad level 2 24 | #define DIS_PIC_SAD_LVL3 5 // Sad level 3 25 | #define DIS_PIC_ALL 6 // Display all 26 | #define DIS_PIN_NULL 7 // Display null 27 | 28 | #define LED_MATRIX_WAKE_PIN 13 29 | 30 | 31 | VMUINT8 led_matrix_check_on_line(); 32 | void led_matrix_disp_string(VMINT8 uData[],VMUINT8 uDataLength,VMUINT16 uTime); 33 | void led_matrix_disp_char(VMUINT8 uData,VMUINT16 uTime); 34 | void led_matrix_set_disp_orientation(VMUINT8 orientation); 35 | void led_matrix_disp_pic(VMUINT8 uPicNum, VMUINT16 uTime); 36 | void led_matrix_power_down(); 37 | void led_matrix_power_wake(); 38 | void led_matrix_do_action(VMUINT32 *pdata); 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/sensor.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __SENSOR_H__ 4 | #define __SENSOR_H__ 5 | 6 | #include 7 | 8 | #define SENSOR_MAX_NUMBER 32 9 | #define SENSOR_HIDDEN_NUMBER 3 10 | 11 | #define U32_TYPE 0 12 | #define I32_TYPE 1 13 | #define F32_TYPE 2 14 | #define P_TYPE 4 // or > 4 15 | 16 | enum sensor_id_t { 17 | ACC_X_ID = 0, 18 | ACC_Y_ID = 1, 19 | ACC_Z_ID = 2, 20 | LIGHT_ID = 3, 21 | TEMPERATURE_ID = 4, 22 | HUMIDITY_ID = 5, 23 | ACC_ID = 6, 24 | CALL_ID = 7, 25 | SMS_ID = 8, 26 | BUTTON_ID = 9 27 | }; 28 | 29 | 30 | typedef struct { 31 | const char *name; 32 | const char *unit; 33 | } sensor_info_t; 34 | 35 | typedef struct { 36 | uint8_t type; 37 | uint8_t reserved; 38 | uint16_t id; 39 | union { 40 | uint32_t u32; 41 | int32_t i32; 42 | float f32; 43 | void *p; 44 | }; 45 | } sensor_t; 46 | 47 | extern const sensor_info_t sensor_info_table[]; 48 | 49 | void sensor_scan(); 50 | sensor_t *sensor_find(uint16_t id); 51 | sensor_t *sensor_get(int index); 52 | int sensor_get_id(int index); 53 | int sensor_get_index(uint16_t id); 54 | char *sensor_get_name(int index); 55 | void sensor_update(); 56 | int sensor_get_number(); 57 | char *sensor_to_string(int index, char *pbuf, int len); 58 | char *sensor_set_title(int index, char *pbuf, int len); 59 | void sensor_set_update_callback(void (*pfunc)(void)); 60 | 61 | #endif // __SENSOR_H__ 62 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/tp_i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef __TP_I2C_H__ 2 | #define __TP_I2C_H__ 3 | 4 | #include "vmtype.h" 5 | #include "vmdrv_tp.h" 6 | 7 | #define CTP_I2C_LOW 0 8 | #define CTP_I2C_HIGH 1 9 | #define CTP_I2C_ACK CTP_I2C_LOW 10 | #define CTP_I2C_NAK CTP_I2C_HIGH 11 | 12 | //delay 13 | void ctp_i2c_udelay(VMUINT32 delay); 14 | 15 | //power on I2C 16 | void ctp_i2c_power_on(VM_DRV_TP_BOOL ON, VMUINT32 ldo, VMUINT32 ldo_volt); 17 | 18 | //configure SW I2C or HW I2C parameters 19 | void ctp_i2c_configure(VMUINT32 slave_addr, VMUINT32 speed); 20 | 21 | // Start bit of I2C waveform 22 | extern void ctp_i2c_start(void); 23 | 24 | // Stop bit of I2C waveform 25 | extern void ctp_i2c_stop(void); 26 | 27 | // Send one byte from host to client 28 | extern VM_DRV_TP_BOOL ctp_i2c_send_byte(VMUINT8 ucData); 29 | 30 | // Receive one byte form client to host 31 | extern VMUINT8 ctp_i2c_receive_byte(VM_DRV_TP_BOOL bAck); 32 | 33 | // I2C send data fuction 34 | extern VM_DRV_TP_BOOL ctp_i2c_send(VMUINT8 ucDeviceAddr, VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 35 | 36 | // I2C receive data function 37 | extern VM_DRV_TP_BOOL ctp_i2c_receive(VMUINT8 ucDeviceAddr, VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 38 | 39 | // I2C send data for 16 bits address fuction 40 | extern VM_DRV_TP_BOOL ctp_i2c_send_ext(VMUINT8 ucDeviceAddr, VMUINT16 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 41 | 42 | // I2C receive data for 16 bits address function 43 | extern VM_DRV_TP_BOOL ctp_i2c_receive_ext(VMUINT8 ucDeviceAddr, VMUINT16 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ugui_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __UGUI_CONFIG_H 2 | #define __UGUI_CONFIG_H 3 | 4 | #include 5 | 6 | /* -------------------------------------------------------------------------------- */ 7 | /* -- CONFIG SECTION -- */ 8 | /* -------------------------------------------------------------------------------- */ 9 | 10 | /* Enable needed fonts here */ 11 | //#define USE_FONT_4X6 12 | //#define USE_FONT_5X8 13 | //#define USE_FONT_5X12 14 | //#define USE_FONT_6X8 15 | //#define USE_FONT_6X10 16 | //#define USE_FONT_7X12 17 | //#define USE_FONT_8X8 18 | //#define USE_FONT_8X12 19 | //#define USE_FONT_8X14 20 | //#define USE_FONT_10X16 21 | //#define USE_FONT_12X16 22 | //#define USE_FONT_12X20 23 | //#define USE_FONT_16X26 24 | //#define USE_FONT_22X36 25 | //#define USE_FONT_24X40 26 | //#define USE_FONT_32X53 27 | #define USE_FONT_ICON48 28 | #define USE_FONT_ICON24 29 | 30 | /* Specify platform-dependent integer types here */ 31 | 32 | #define __UG_FONT_DATA const 33 | typedef uint8_t UG_U8; 34 | typedef int8_t UG_S8; 35 | typedef uint16_t UG_U16; 36 | typedef int16_t UG_S16; 37 | typedef uint32_t UG_U32; 38 | typedef int32_t UG_S32; 39 | 40 | 41 | /* Example for dsPIC33 42 | typedef unsigned char UG_U8; 43 | typedef signed char UG_S8; 44 | typedef unsigned int UG_U16; 45 | typedef signed int UG_S16; 46 | typedef unsigned long int UG_U32; 47 | typedef signed long int UG_S32; 48 | */ 49 | 50 | /* -------------------------------------------------------------------------------- */ 51 | /* -------------------------------------------------------------------------------- */ 52 | 53 | 54 | /* Feature enablers */ 55 | #define USE_PRERENDER_EVENT 56 | #define USE_POSTRENDER_EVENT 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/actuator.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "actuator.h" 4 | 5 | extern void led_matrix_window_show(uint32_t *pdata); 6 | extern void led_matrix_do_action(uint32_t *pdata); 7 | extern void ws2812_window_show(uint32_t *pdata); 8 | extern void rgb_ws2812_do_action(uint32_t *); 9 | extern void music_window_show(uint32_t *pdata); 10 | extern void music_do_action(uint32_t *pdata); 11 | extern void call_action_window_show(uint32_t *pdata); 12 | extern void call_do_action(uint32_t *pdata); 13 | extern void sms_action_window_show(uint32_t *pdata); 14 | extern void sms_do_action(uint32_t *pdata); 15 | 16 | char *g_actuator_name_list[] = {"LED matrix", "color pixels", "music", "call", "SMS"}; 17 | actuator_pfunc_t g_actuator_get_data_function_list[] = { 18 | led_matrix_window_show, 19 | ws2812_window_show, 20 | music_window_show, 21 | call_action_window_show, 22 | sms_action_window_show 23 | }; 24 | 25 | actuator_pfunc_t g_actuator_do_action_function_list[] = { 26 | led_matrix_do_action, 27 | rgb_ws2812_do_action, 28 | music_do_action, 29 | call_do_action, 30 | sms_do_action, 31 | }; 32 | 33 | 34 | int actuator_get_number() 35 | { 36 | return sizeof(g_actuator_name_list) / sizeof(*g_actuator_name_list); 37 | } 38 | 39 | char *actuator_get_name(int index) 40 | { 41 | return g_actuator_name_list[index]; 42 | } 43 | 44 | action_pfunc_t actuator_get_action_function(int index) 45 | { 46 | return g_actuator_do_action_function_list[index]; 47 | } 48 | 49 | int actuator_get_action_data(int index, uint32_t *pdata) 50 | { 51 | actuator_pfunc_t pfunc = g_actuator_get_data_function_list[index]; 52 | if (pfunc) { 53 | pfunc(pdata); 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | char *actuator_get_action_name(actuator_pfunc_t pfunc) 60 | { 61 | int i; 62 | for (i = 0; i < sizeof(g_actuator_do_action_function_list); i++) { 63 | if (pfunc == g_actuator_do_action_function_list[i]) { 64 | return g_actuator_name_list[i]; 65 | } 66 | } 67 | 68 | return ""; 69 | } 70 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/action.c: -------------------------------------------------------------------------------- 1 | 2 | #include "action.h" 3 | #include "actuator.h" 4 | #include "vmmemory.h" 5 | 6 | action_pfunc_t g_action_pfunc_list[ACTION_MAX_NUMBER] = {0,}; 7 | uint32_t g_action_data_table[ACTION_MAX_NUMBER][3] = {0,}; 8 | uint32_t g_action_mask = 0; 9 | 10 | extern void call_do_action(uint32_t *pdata); 11 | extern void sms_do_action(uint32_t *pdata); 12 | 13 | int action_add(action_pfunc_t pfunc) 14 | { 15 | int index = 0; 16 | while (g_action_mask & (1 << index)) { 17 | index++; 18 | } 19 | if (index >= ACTION_MAX_NUMBER) { 20 | return -1; 21 | } 22 | 23 | if (pfunc == call_do_action) { 24 | g_action_data_table[index][0] = (uint32_t)vm_malloc(16); 25 | } else if (pfunc == sms_do_action) { 26 | g_action_data_table[index][0] = (uint32_t)vm_malloc(16 + 40); 27 | } 28 | 29 | g_action_mask |= (uint32_t)1 << index; 30 | g_action_pfunc_list[index] = pfunc; 31 | 32 | return index; 33 | } 34 | 35 | int action_exec(int action_id) 36 | { 37 | action_pfunc_t pfunc; 38 | if ((action_id >= ACTION_MAX_NUMBER) || !((g_action_mask >> action_id) & 1)) { 39 | return 0; 40 | } 41 | 42 | pfunc = g_action_pfunc_list[action_id]; 43 | if (pfunc) { 44 | return pfunc(g_action_data_table[action_id]); 45 | } 46 | 47 | return 0; 48 | } 49 | 50 | void action_remove(int action_id) 51 | { 52 | if ((action_id < ACTION_MAX_NUMBER) && ((g_action_mask >> action_id) & 1)) { 53 | if (g_action_pfunc_list[action_id] == call_do_action) { 54 | vm_free((void *)g_action_data_table[action_id][0]); 55 | } else if (g_action_pfunc_list[action_id] == sms_do_action) { 56 | vm_free((void *)g_action_data_table[action_id][0]); 57 | } 58 | 59 | g_action_mask &= ~((uint32_t)1 << action_id); 60 | g_action_pfunc_list[action_id] = 0; 61 | } 62 | } 63 | 64 | void action_set_function(int index, int (*pfunc)(void *)) 65 | { 66 | g_action_pfunc_list[index] = pfunc; 67 | } 68 | 69 | uint32_t *action_get_data(int index) 70 | { 71 | return g_action_data_table[index]; 72 | } 73 | 74 | char *action_to_string(int index, char *pbuf, int len) 75 | { 76 | if (g_action_pfunc_list[index] == call_do_action) { 77 | snprintf(pbuf, len, "call %s", (char *)g_action_data_table[index][0]); 78 | } else if (g_action_pfunc_list[index] == sms_do_action) { 79 | snprintf(pbuf, len, "text %s", (char *)g_action_data_table[index][0]); 80 | } else { 81 | snprintf(pbuf, len, "set %s", actuator_get_action_name(g_action_pfunc_list[index])); 82 | } 83 | return pbuf; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MediaTek Inc 6 | Demo 7 | 2.0.0 8 | -1 9 | 10 | 11 | 12 | 13 | Audio 14 | Call 15 | Camera 16 | TCP 17 | File 18 | HTTP 19 | Sensor 20 | SIM card 21 | Record 22 | SMS(person) 23 | SMS(SP) 24 | BitStream 25 | Contact 26 | LBS 27 | MMS 28 | ProMng 29 | SMSMng 30 | Video 31 | XML 32 | Sec 33 | SysStorage 34 | Payment 35 | BT 36 | PUSH 37 | UDP 38 | SysFile 39 | sso 40 | Mediatek; Standard; Memory; Framework; Comman 41 | 42 | 43 | 800 44 | checked 45 | unchecked 46 | unchecked 47 | checked 48 | unchecked 49 | 50 | 51 | unchecked 52 | -1 53 | 54 | 55 | unchecked 56 | unchecked 57 | unchecked 58 | 59 | 60 | Demo 61 | Demo 62 | Demo 63 | 64 | 65 | content 66 | 1234567890 67 | 68 | 69 | Internal 70 | 1234567890 71 | 72 | 73 | 0 74 | 2 75 | 76 | 77 | 128 78 | 160 79 | 80 | 81 | 10 82 | 0 83 | 2 84 | 85 | 86 | 12 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/sms_book.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmlog.h" 3 | #include "sms_book.h" 4 | #include "lstorage.h" 5 | #include 6 | #include 7 | 8 | 9 | char sms_content[ADDRESS_MAX][CONTENT_LEN_MAX]; 10 | int item_num; 11 | 12 | 13 | void sms_book_open() 14 | { 15 | unsigned long len; 16 | unsigned long i; 17 | item_num = 0; 18 | 19 | file_open("sms_book.txt"); 20 | file_size("sms_book.txt", &len); 21 | 22 | if(len > 2) 23 | { 24 | char str_tmp[ADDRESS_MAX*(CONTENT_LEN_MAX+5)]; 25 | file_read("sms_book.txt", str_tmp, len, 0); 26 | 27 | for(i=0; i= ADDRESS_MAX)item_num = ADDRESS_MAX; 35 | } 36 | } 37 | } 38 | 39 | void sms_book_add(char* content) 40 | { 41 | if(content == 0)return; 42 | if(item_num == ADDRESS_MAX)return; 43 | 44 | if(item_num == 0) 45 | { 46 | strcpy(sms_content[0], content); 47 | 48 | item_num++; 49 | sms_save(); 50 | 51 | return; 52 | } 53 | 54 | int is_exist = sms_book_find(content); 55 | 56 | // if this item exist 57 | if(is_exist>=0) 58 | { 59 | return; 60 | } 61 | 62 | char str_dbg[151]; 63 | int min = 0; 64 | int max = item_num; 65 | 66 | while(min != max) 67 | { 68 | int tmp = (max+min)/2; 69 | 70 | min = strcmp(content, sms_content[tmp])>0 ? tmp+1 : min; 71 | max = strcmp(content, sms_content[tmp])<0 ? tmp : max; 72 | } 73 | 74 | int i; 75 | for(i=item_num; i>min; i--) 76 | { 77 | strcpy(sms_content[i], sms_content[i-1]); 78 | } 79 | 80 | strcpy(sms_content[min], content); 81 | 82 | item_num++; 83 | sms_save(); 84 | } 85 | 86 | int sms_book_find(char* content) 87 | { 88 | int i; 89 | 90 | if(content == 0)return -2; 91 | 92 | for(i=0; i> 16) & 0xff); 53 | DataBuf[2] = ((ulRGB >> 8) & 0xff); 54 | DataBuf[3] = (ulRGB & 0xff); 55 | 56 | dlc_i2c_send(RGB_SET_WORK, DataBuf, 4); 57 | } 58 | 59 | void rgb_ws2812_monochrome(uint8_t ucNum, uint32_t ulRGBData, uint16_t uiTime) 60 | { 61 | uint8_t DataBuf[7] = {0}; 62 | 63 | DataBuf[0] = RGB_MONOCHROME; 64 | DataBuf[1] = ucNum; 65 | DataBuf[2] = (ulRGBData >> 16) & 0xff; 66 | DataBuf[3] = (ulRGBData >> 8) & 0xff; 67 | DataBuf[4] = ulRGBData & 0xff; 68 | DataBuf[5] = (uiTime >> 8) & 0xff; 69 | DataBuf[6] = uiTime & 0xff; 70 | 71 | dlc_i2c_configure(RGB_WS2812_Address, 100); 72 | dlc_i2c_send(RGB_SET_MODE, DataBuf, 7); 73 | } 74 | 75 | void rgb_ws2812_marquee(uint8_t ucNum, uint32_t ulRGBData, uint16_t uiTime) 76 | { 77 | uint8_t DataBuf[7] = {0}; 78 | 79 | DataBuf[0] = RGB_MARQUEE; 80 | DataBuf[1] = ucNum; 81 | DataBuf[2] = (ulRGBData >> 16) & 0xff; 82 | DataBuf[3] = (ulRGBData >> 8) & 0xff; 83 | DataBuf[4] = ulRGBData & 0xff; 84 | DataBuf[5] = (uiTime >> 8) & 0xff; 85 | DataBuf[6] = uiTime & 0xff; 86 | 87 | dlc_i2c_configure(RGB_WS2812_Address, 100); 88 | dlc_i2c_send(RGB_SET_MODE, DataBuf, 7); 89 | } 90 | 91 | void rgb_ws2812_rainbow(uint8_t ucNum, uint16_t uiTime) 92 | { 93 | uint8_t DataBuf[4] = {0}; 94 | 95 | DataBuf[0] = RGB_RAINBOW; 96 | DataBuf[1] = ucNum; 97 | DataBuf[2] = (uiTime >> 8) & 0xff; 98 | DataBuf[3] = uiTime & 0xff; 99 | 100 | dlc_i2c_configure(RGB_WS2812_Address, 100); 101 | dlc_i2c_send(RGB_SET_MODE, DataBuf, 4); 102 | } 103 | 104 | void rgb_ws2812_do_action(uint32_t *pdata) 105 | { 106 | uint8_t mode = pdata[0] >> 16; 107 | uint8_t number = pdata[0] & 0xFF; 108 | uint16_t time = pdata[1]; 109 | uint32_t color = pdata[2]; 110 | 111 | vm_log_info("ws2812 - mode: %d, n: %d, time: %d (%d), color: 0x%X", mode, number, time, pdata[1], color); 112 | 113 | if (mode == 0) { 114 | rgb_ws2812_monochrome(number, color, time); 115 | } else if (mode == 1) { 116 | rgb_ws2812_marquee(number, color, time); 117 | } else { 118 | rgb_ws2812_rainbow(number, time); 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lledmatrix.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmtype.h" 3 | #include "vmlog.h" 4 | //#include "ldlci2cV1.h" 5 | #include "ldlci2cV2.h" 6 | #include "lledmatrix.h" 7 | #include "ldlcgpio.h" 8 | 9 | 10 | static void delay_ms(VMUINT32 millisecs) 11 | { 12 | VMUINT32 timeStop; 13 | VMUINT32 timeStart; 14 | VMUINT32 Freq = 0; 15 | volatile VMUINT32 i; 16 | millisecs = millisecs*1000; 17 | 18 | timeStart = vm_time_ust_get_count(); 19 | while( Freq < millisecs) 20 | { 21 | for(i=0;i<5000;i++){} 22 | timeStop = vm_time_ust_get_count(); 23 | Freq = timeStop - timeStart + 1; 24 | } 25 | } 26 | 27 | void led_matrix_power_down() 28 | { 29 | dlc_i2c_configure(LEDAddress, 100); 30 | dlc_i2c_send_byte(POWER_DOWN); 31 | } 32 | 33 | void led_matrix_power_wake() 34 | { 35 | pinMode(LED_MATRIX_WAKE_PIN,OUTPUT); 36 | digitalWrite(LED_MATRIX_WAKE_PIN,0); 37 | delay_ms(1); 38 | digitalWrite(LED_MATRIX_WAKE_PIN,1); 39 | } 40 | 41 | VMUINT8 led_matrix_check_on_line() 42 | { 43 | VMUINT8 DataBuf[4] = {0}; 44 | 45 | dlc_i2c_configure(LEDAddress, 100); 46 | 47 | DataBuf[0] = dlc_i2c_receive_byte(NULL); 48 | DataBuf[1] = dlc_i2c_receive_byte(NULL); 49 | DataBuf[2] = dlc_i2c_receive_byte(NULL); 50 | DataBuf[3] = dlc_i2c_receive_byte(NULL); 51 | 52 | //m_log_info("led matrix check data is %x %x %x %x",DataBuf[0],DataBuf[1],DataBuf[2],DataBuf[3]); 53 | 54 | if(DataBuf[3] == LEDAddress) 55 | { 56 | //vm_log_info("led matrix is on line."); 57 | return TRUE; 58 | } 59 | else 60 | { 61 | //vm_log_info("led matrix is not on line."); 62 | return FALSE; 63 | } 64 | } 65 | 66 | void led_matrix_disp_string(VMINT8 uData[],VMUINT8 uDataLength,VMUINT16 uTime) 67 | { 68 | ///* 69 | VMINT8 buffer[20] = {0}; 70 | VMUINT8 i; 71 | if(uDataLength > 4)return; 72 | buffer[0] = uDataLength; 73 | for(i=0;i> 8; 75 | buffer[i+2] = uTime; 76 | 77 | dlc_i2c_configure(LEDAddress, 100); 78 | dlc_i2c_send(DISP_STRING, buffer, uDataLength + 3); 79 | //*/ 80 | /* 81 | masterBegin(); 82 | beginTransmission(LEDAddress); 83 | write(DISP_STRING); 84 | write(uDataLength); 85 | write_ext((VMINT8*)uData,uDataLength); 86 | write(uTime>>8); //high byte of time 87 | write(uTime); //low byte of time 88 | endTransmission(); 89 | */ 90 | } 91 | 92 | void led_matrix_disp_char(VMUINT8 uData,VMUINT16 uTime) 93 | { 94 | ///* 95 | VMUINT8 buffer[3] = {0}; 96 | buffer[0] = uData; 97 | buffer[1] = uTime >> 8; 98 | buffer[2] = uTime; 99 | 100 | dlc_i2c_configure(LEDAddress, 100); 101 | dlc_i2c_send(DISP_CHAR_5X7, buffer, 3); 102 | //*/ 103 | /* 104 | beginTransmission(LEDAddress); 105 | write(DISP_CHAR_5X7); 106 | write(uData); 107 | write(uTime>>8); //high byte of time 108 | write(uTime); //low byte of time 109 | endTransmission(); 110 | */ 111 | } 112 | 113 | void led_matrix_set_disp_orientation(VMUINT8 orientation) 114 | { 115 | dlc_i2c_configure(LEDAddress, 100); 116 | dlc_i2c_send(SET_DISP_ORIENTATION, &orientation, 1); 117 | } 118 | 119 | void led_matrix_disp_pic(VMUINT8 uPicNum, VMUINT16 uTime) 120 | { 121 | VMUINT8 buffer[3] = {0}; 122 | buffer[0] = uPicNum; 123 | buffer[1] = uTime >> 8; 124 | buffer[2] = uTime; 125 | 126 | dlc_i2c_configure(LEDAddress, 100); 127 | dlc_i2c_send(DISP_PIC, buffer, 3); 128 | } 129 | 130 | void led_matrix_do_action(VMUINT32 *pdata) 131 | { 132 | char ch = pdata[0]; 133 | int duration = pdata[1]; 134 | led_matrix_disp_char(ch, duration); 135 | } 136 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/address_book.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmlog.h" 3 | #include "address_book.h" 4 | #include "lstorage.h" 5 | #include 6 | #include 7 | 8 | 9 | char book_name[ADDRESS_MAX][NAME_LEN_MAX]; 10 | char book_num[ADDRESS_MAX][NUM_LEN_MAX]; 11 | static int g_book_item_number; 12 | 13 | 14 | void book_open() 15 | { 16 | unsigned long len; 17 | unsigned long i; 18 | g_book_item_number = 0; 19 | 20 | file_open("address_book.txt"); 21 | file_size("address_book.txt", &len); 22 | 23 | if(len > 4) 24 | { 25 | char str_tmp[ADDRESS_MAX*(NAME_LEN_MAX+NUM_LEN_MAX+5)]; 26 | file_read("address_book.txt", str_tmp, len, 0); 27 | 28 | for(i=0; i= ADDRESS_MAX)g_book_item_number = ADDRESS_MAX; 37 | } 38 | } 39 | } 40 | 41 | void book_add(char* name, char* num) 42 | { 43 | if(name == 0 || num == 0)return; 44 | if(g_book_item_number == ADDRESS_MAX)return; 45 | 46 | if(g_book_item_number == 0) 47 | { 48 | strcpy(book_name[0], name); 49 | strcpy(book_num[0], num); 50 | 51 | g_book_item_number++; 52 | book_save(); 53 | 54 | return; 55 | } 56 | 57 | int is_exist = book_find(name); 58 | 59 | // if this item exist 60 | if(is_exist>=0) 61 | { 62 | strcpy(book_num[is_exist], num); 63 | book_save(); 64 | 65 | return; 66 | } 67 | 68 | char str_dbg[50]; 69 | int min = 0; 70 | int max = g_book_item_number; 71 | 72 | while(min != max) 73 | { 74 | int tmp = (max+min)/2; 75 | 76 | min = strcmp(name, book_name[tmp])>0 ? tmp+1 : min; 77 | max = strcmp(name, book_name[tmp])<0 ? tmp : max; 78 | } 79 | 80 | int i; 81 | for(i=g_book_item_number; i>min; i--) 82 | { 83 | strcpy(book_name[i], book_name[i-1]); 84 | strcpy(book_num[i], book_num[i-1]); 85 | } 86 | 87 | strcpy(book_num[min], num); 88 | strcpy(book_name[min], name); 89 | 90 | g_book_item_number++; 91 | book_save(); 92 | } 93 | 94 | int book_find(char* name) 95 | { 96 | int i; 97 | 98 | if(name == 0)return -2; 99 | 100 | for(i=0; itype == MSG_TYPE_OBJECT) { 27 | if (msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 28 | switch (msg->sub_id) { 29 | case 1: 30 | input_window_show(g_vibrator_time_str, sizeof(g_vibrator_time_str), 1); 31 | break; 32 | case 2: 33 | UG_WindowShow(g_vibrator_window_prev); 34 | break; 35 | case 3: 36 | g_vibrator_time = atoi(g_vibrator_time_str); 37 | 38 | if (g_vibrator_parameters) { 39 | g_vibrator_parameters[0] = g_vibrator_time; 40 | } else { 41 | motor_do_action(&g_vibrator_time); 42 | } 43 | 44 | UG_WindowShow(g_vibrator_window_prev); 45 | break; 46 | } 47 | 48 | } 49 | } 50 | } 51 | 52 | void vibrator_window_create(void) 53 | { 54 | static UG_BUTTON buttons[6]; 55 | static UG_OBJECT objects[6]; 56 | char *button_texts[] = { "Run Time (s)", ""}; 57 | int offset; 58 | 59 | UG_WindowCreate(&g_vibrator_window, objects, 60 | sizeof(objects) / sizeof(*objects), vibrator_window_callback); 61 | UG_WindowSetStyle(&g_vibrator_window, WND_STYLE_2D); 62 | 63 | 64 | for (offset = 0; offset < 2; offset++) { 65 | UG_ButtonCreate(&g_vibrator_window, buttons + offset, offset, 0, 66 | 40 * offset + 40, 239, 40 * offset + 80 - 1); 67 | UG_ButtonSetFont(&g_vibrator_window, offset, &FONT_SIZE20); 68 | 69 | if (offset % 2) { 70 | UG_ButtonSetStyle(&g_vibrator_window, offset, 71 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 72 | } else { 73 | UG_ButtonSetStyle(&g_vibrator_window, offset, 74 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 75 | UG_ButtonSetBackColor(&g_vibrator_window, offset, 0); 76 | } 77 | 78 | UG_ButtonSetAlignment(&g_vibrator_window, offset, ALIGN_CENTER_LEFT); 79 | UG_ButtonSetHSpace(&g_vibrator_window, offset, 8); 80 | 81 | UG_ButtonSetText(&g_vibrator_window, offset, 82 | button_texts[offset]); 83 | } 84 | 85 | UG_ButtonCreate(&g_vibrator_window, buttons + offset, offset, 0, 86 | 200, 119, 239); 87 | UG_ButtonSetFont(&g_vibrator_window, offset, &FONT_ICON24); 88 | UG_ButtonSetText(&g_vibrator_window, offset, "1"); 89 | UG_ButtonSetStyle(&g_vibrator_window, offset, 90 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 91 | 92 | offset++; 93 | UG_ButtonCreate(&g_vibrator_window, buttons + offset, offset, 120, 94 | 200, 239, 239); 95 | UG_ButtonSetFont(&g_vibrator_window, offset, &FONT_ICON24); 96 | UG_ButtonSetText(&g_vibrator_window, offset, ":"); 97 | UG_ButtonSetStyle(&g_vibrator_window, offset, 98 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 99 | 100 | offset++; 101 | UG_ButtonCreate(&g_vibrator_window, buttons + offset, offset, 0, 0, 239, 39); 102 | UG_ButtonSetFont(&g_vibrator_window, offset, &FONT_SIZE20); 103 | UG_ButtonSetText(&g_vibrator_window, offset, "Vibrator"); 104 | UG_ButtonSetStyle(&g_vibrator_window, offset, 105 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 106 | UG_ButtonSetBackColor(&g_vibrator_window, offset, 0x000000); 107 | } 108 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/input_window.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "ugui.h" 4 | 5 | 6 | static int g_from_button_id = 0; 7 | UG_WINDOW g_input_window; 8 | static const char *g_input_button_text[15] = { "1", "2", "3", "4", "5", "6", "7", "8", 9 | "9", "-", "0", ".", 10 | "1", ":", "7" // ICON FONT 11 | }; 12 | static char *g_input_string; 13 | static uint8_t g_input_string_length = 0; 14 | static uint8_t g_input_string_max_length = 0; 15 | 16 | static void input_window_callback(UG_MESSAGE *msg) 17 | { 18 | if (msg->type == MSG_TYPE_OBJECT) { 19 | if (msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 20 | switch (msg->sub_id) { 21 | case 15: // text 22 | break; 23 | case 12: // return 24 | UG_WindowShow(UG_GetLastWindow()); 25 | break; 26 | case 13: // return string 27 | UG_ButtonSetText(UG_GetLastWindow(), g_from_button_id, g_input_string); 28 | UG_WindowShow(UG_GetLastWindow()); 29 | break; 30 | case 14: // delete 31 | if (g_input_string_length > 0) { 32 | g_input_string_length--; 33 | g_input_string[g_input_string_length] = 34 | '\0'; 35 | UG_ButtonSetText(&g_input_window, 15, 36 | g_input_string); 37 | } 38 | break; 39 | default: 40 | if (g_input_string_length 41 | < (g_input_string_max_length - 1)) { 42 | int index = msg->sub_id; 43 | g_input_string[g_input_string_length] = 44 | *g_input_button_text[index]; 45 | UG_ButtonSetText(&g_input_window, 15, 46 | g_input_string); 47 | g_input_string_length++; 48 | g_input_string[g_input_string_length] = 49 | '\0'; 50 | } 51 | } 52 | } 53 | } 54 | } 55 | 56 | void input_window_create(void) 57 | { 58 | static UG_BUTTON buttons[16]; 59 | static UG_OBJECT objects[16]; 60 | int i = 0; 61 | int j = 0; 62 | 63 | UG_WindowCreate(&g_input_window, objects, 16, input_window_callback); 64 | UG_WindowSetStyle(&g_input_window, WND_STYLE_2D); 65 | 66 | for (i = 0; i < 4; i++) { 67 | for (j = 0; j < 3; j++) { 68 | int index = i * 3 + j; 69 | UG_ButtonCreate(&g_input_window, buttons + index, index, 80 * j, 70 | 40 * (i + 1), 80 * (j + 1) - 1, 40 * (i + 2) - 1); 71 | UG_ButtonSetFont(&g_input_window, index, &FONT_SIZE20); 72 | UG_ButtonSetText(&g_input_window, index, g_input_button_text[index]); 73 | UG_ButtonSetStyle(&g_input_window, index, 74 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS 75 | | BTN_STYLE_NO_BORDERS); 76 | } 77 | } 78 | 79 | for (j = 0; j < 3; j++) { 80 | int index = 4 * 3 + j; 81 | UG_ButtonCreate(&g_input_window, buttons + index, index, 80 * j, 82 | 40 * (i + 1), 80 * (j + 1) - 1, 40 * (i + 2) - 1); 83 | UG_ButtonSetFont(&g_input_window, index, &FONT_ICON24); 84 | UG_ButtonSetText(&g_input_window, index, g_input_button_text[index]); 85 | UG_ButtonSetStyle(&g_input_window, index, 86 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 87 | } 88 | 89 | UG_ButtonCreate(&g_input_window, buttons + 15, 15, 0, 0, 90 | 239, 39); 91 | UG_ButtonSetFont(&g_input_window, 15, &FONT_SIZE20); 92 | UG_ButtonSetText(&g_input_window, 15, 93 | g_input_string); 94 | UG_ButtonSetStyle(&g_input_window, 15, 95 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 96 | UG_ButtonSetBackColor(&g_input_window, 15, 0); 97 | 98 | // UG_ButtonSetBackColor(&g_input_window, 13, 0x4CAF50); 99 | } 100 | 101 | void input_window_show(char *buf, int len, int id) 102 | { 103 | g_from_button_id = id; 104 | 105 | g_input_string = buf; 106 | g_input_string_max_length = len; 107 | g_input_string_length = 0; 108 | UG_ButtonSetText(&g_input_window, 15, ""); 109 | UG_WindowShow(&g_input_window); 110 | } 111 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/condition.c: -------------------------------------------------------------------------------- 1 | 2 | #include "condition.h" 3 | #include 4 | #include "vmlog.h" 5 | #include "vmmemory.h" 6 | 7 | condition_t g_condition_list[CONDITION_MAX_NUMBER] = {0,}; 8 | uint32_t g_condition_mask = 0; 9 | 10 | 11 | int condition_add(sensor_t *sensor) 12 | { 13 | int index = 0; 14 | while (g_condition_mask & (1 << index)) { 15 | index++; 16 | } 17 | if (index >= CONDITION_MAX_NUMBER) { 18 | return -1; 19 | } 20 | 21 | g_condition_mask |= (uint32_t)1 << index; 22 | g_condition_list[index].type = sensor->type; 23 | g_condition_list[index].id = sensor->id; 24 | g_condition_list[index].u32 = sensor->u32; 25 | g_condition_list[index].op = '='; 26 | 27 | 28 | if (g_condition_list[index].type > 4) { 29 | g_condition_list[index].p = vm_malloc(sensor->type); 30 | } 31 | 32 | return index; 33 | } 34 | 35 | int condition_check(int index) 36 | { 37 | condition_t *pcondition; 38 | sensor_t *psensor; 39 | 40 | pcondition = g_condition_list + index; 41 | psensor = sensor_find(pcondition->id); 42 | 43 | if (!psensor) { 44 | return 0; 45 | } 46 | 47 | if (pcondition->op == '=') { 48 | if (pcondition->type < P_TYPE) { 49 | return pcondition->u32 == psensor->u32 ? 1 : 0; 50 | } else { 51 | if (pcondition->id == CALL_ID || pcondition->id == SMS_ID) { 52 | if (*(char *)pcondition->p == 'a' && psensor->p) { 53 | return 1; 54 | } 55 | } 56 | 57 | if (strcmp((char *)pcondition->p, (char *)psensor->p)) { 58 | return 0; 59 | } else { 60 | return 1; 61 | } 62 | } 63 | } else if (pcondition->op == '<') { 64 | if (pcondition->type == U32_TYPE) { 65 | return pcondition->u32 > psensor->u32 ? 1 : 0; 66 | } else if (pcondition->type == I32_TYPE) { 67 | return pcondition->i32 > psensor->i32 ? 1 : 0; 68 | } else if (pcondition->type == F32_TYPE) { 69 | return pcondition->f32 > psensor->f32 ? 1 : 0; 70 | } else { 71 | return 0; 72 | } 73 | } else if (pcondition->op == '>') { 74 | if (pcondition->type == U32_TYPE) { 75 | return pcondition->u32 < psensor->u32 ? 1 : 0; 76 | } else if (pcondition->type == I32_TYPE) { 77 | return pcondition->i32 < psensor->i32 ? 1 : 0; 78 | } else if (pcondition->type == F32_TYPE) { 79 | return pcondition->f32 < psensor->f32 ? 1 : 0; 80 | } else { 81 | return 0; 82 | } 83 | } 84 | 85 | return 0; 86 | } 87 | 88 | condition_t *condition_get(int index) 89 | { 90 | return g_condition_list + index; 91 | } 92 | 93 | void condition_remove(int index) 94 | { 95 | if (index < CONDITION_MAX_NUMBER && (g_condition_mask >> index) & 1) { 96 | g_condition_mask &= ~((uint32_t)1 << index); 97 | 98 | if (g_condition_list[index].type > 4) { 99 | vm_malloc(g_condition_list[index].p); 100 | } 101 | } 102 | } 103 | 104 | void condition_set_value(int index, char *str) 105 | { 106 | condition_t *ptr = g_condition_list + index; 107 | 108 | if (ptr->type == U32_TYPE || ptr->type == I32_TYPE) { 109 | ptr->i32 = atoi(str); 110 | } else if (ptr->type == F32_TYPE) { 111 | ptr->f32 = atof(str); 112 | } else { 113 | strcpy((char *)ptr->p, str); 114 | } 115 | } 116 | 117 | void *condition_get_value(int index) 118 | { 119 | return g_condition_list[index].p; 120 | } 121 | 122 | void condition_set_operator(int index, uint8_t op) 123 | { 124 | condition_t *ptr = g_condition_list + index; 125 | ptr->op = op; 126 | } 127 | 128 | char *condition_to_string(int index, char *pbuf, int len) 129 | { 130 | condition_t *pdata = g_condition_list + index; 131 | int id = pdata->id; 132 | if (id == BUTTON_ID) { 133 | snprintf(pbuf, len, "button is pressed"); 134 | } else if (id == CALL_ID || id == SMS_ID) { 135 | snprintf(pbuf, len, "%s from %s", sensor_info_table[id].name, (char *)(pdata->p)); 136 | } else { 137 | if (pdata->type == F32_TYPE) { 138 | snprintf(pbuf, len, "%s %c %0.3f %s", sensor_info_table[id].name, pdata->op, pdata->f32, sensor_info_table[id].unit); 139 | } else if (pdata->type == I32_TYPE) { 140 | snprintf(pbuf, len, "%s %c %d %s", sensor_info_table[id].name, pdata->op, pdata->i32, sensor_info_table[id].unit); 141 | } else { 142 | snprintf(pbuf, len, "%s %c %u %s", sensor_info_table[id].name, pdata->op, pdata->u32, sensor_info_table[id].unit); 143 | } 144 | } 145 | 146 | return pbuf; 147 | } 148 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/sensor.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "ldlci2cV2.h" 4 | #include "sensor.h" 5 | #include "ifttt.h" 6 | 7 | 8 | const sensor_info_t sensor_info_table[] = { 9 | {"acc.x", "mG"}, 10 | {"acc.y", "mG"}, 11 | {"acc.z", "mG"}, 12 | {"light", "Lux"}, 13 | {"temperature", "C"}, 14 | {"humidity", "%"}, 15 | {"acc", "mG"}, 16 | {"call", ""}, 17 | {"sms", ""}, 18 | {"button", ""}, 19 | }; 20 | 21 | static int g_sensor_number = 0; 22 | static sensor_t g_sensor_list[SENSOR_MAX_NUMBER] = {0,}; 23 | static uint32_t g_new_sensor_data_mask = 0; 24 | static void (*p_sensor_changed_callback)(void) = 0; 25 | 26 | void sensor_scan() 27 | { 28 | sensor_t *psensor; 29 | uint32_t device_info; 30 | uint8_t number; 31 | int i; 32 | 33 | dlc_i2c_configure(0x03, 100); 34 | dlc_i2c_receive(0x0, &device_info, 4); 35 | 36 | number = device_info >> 24; 37 | 38 | psensor = g_sensor_list + g_sensor_number; 39 | for (i = 0; i < number; i++) { 40 | dlc_i2c_receive(4 + 8 * i, psensor, 8); 41 | psensor++; 42 | g_new_sensor_data_mask |= (uint32_t)1 << i; 43 | } 44 | 45 | g_sensor_number += number; 46 | 47 | psensor->type = 16; // P_TYPE, require 16 extra bytes memory 48 | psensor->id = CALL_ID; 49 | psensor->p = 0; 50 | g_sensor_number++; 51 | 52 | psensor++; 53 | psensor->type = 16; // P_TYPE, require 16 extra bytes memory 54 | psensor->id = SMS_ID; 55 | psensor->p = 0; 56 | g_sensor_number++; 57 | 58 | psensor++; 59 | psensor->type = U32_TYPE; 60 | psensor->id = BUTTON_ID; 61 | psensor->u32 = 0; 62 | g_sensor_number++; 63 | } 64 | 65 | int sensor_get_number() 66 | { 67 | return g_sensor_number; 68 | } 69 | 70 | void sensor_update() 71 | { 72 | uint32_t device_info; 73 | uint32_t new_sensor_data_flag; 74 | sensor_t sensor; 75 | int sensor_index; 76 | int i; 77 | 78 | dlc_i2c_configure(0x03, 100); 79 | 80 | // flag 81 | dlc_i2c_receive(0x0, &device_info, 4); 82 | new_sensor_data_flag = device_info & 0x0FFF; 83 | 84 | i = 0; 85 | while (new_sensor_data_flag) { 86 | if (new_sensor_data_flag & 1) { 87 | dlc_i2c_receive(4 + 8 * i, &sensor, 8); 88 | 89 | sensor_index = sensor_get_index(sensor.id); 90 | if (sensor_index >= 0) { 91 | g_sensor_list[sensor_index].u32 = sensor.u32; 92 | 93 | g_new_sensor_data_mask |= (uint32_t)1 << sensor_index; 94 | } else { 95 | 96 | } 97 | } 98 | 99 | i++; 100 | new_sensor_data_flag >>= 1; 101 | } 102 | 103 | if (p_sensor_changed_callback) { 104 | p_sensor_changed_callback(); 105 | } 106 | 107 | ifttt_check(); 108 | } 109 | 110 | sensor_t *sensor_find(uint16_t id) 111 | { 112 | int i; 113 | for (i = 0; i < g_sensor_number; i++) { 114 | if (g_sensor_list[i].id == id) { 115 | return g_sensor_list + i; 116 | } 117 | } 118 | 119 | return 0; 120 | } 121 | 122 | sensor_t *sensor_get(int index) 123 | { 124 | return g_sensor_list + index; 125 | } 126 | 127 | int sensor_get_id(int index) 128 | { 129 | return g_sensor_list[index].id; 130 | } 131 | 132 | int sensor_get_index(uint16_t id) 133 | { 134 | int i; 135 | for (i = 0; i < g_sensor_number; i++) { 136 | if (g_sensor_list[i].id == id) { 137 | return i; 138 | } 139 | } 140 | 141 | return -1; 142 | } 143 | 144 | char *sensor_get_name(int index) 145 | { 146 | return sensor_info_table[g_sensor_list[index].id].name; 147 | } 148 | 149 | char *sensor_to_string(int index, char *pbuf, int len) 150 | { 151 | sensor_t *pdata = g_sensor_list + index; 152 | int id = pdata->id; 153 | if (pdata->type == F32_TYPE) { 154 | snprintf(pbuf, len, "%s: %0.3f %s", sensor_info_table[id].name, pdata->f32, sensor_info_table[id].unit); 155 | } else if (pdata->type == I32_TYPE) { 156 | snprintf(pbuf, len, "%s: %d %s", sensor_info_table[id].name, pdata->i32, sensor_info_table[id].unit); 157 | } else if (pdata->type == U32_TYPE) { 158 | snprintf(pbuf, len, "%s: %u %s", sensor_info_table[id].name, pdata->u32, sensor_info_table[id].unit); 159 | } else { 160 | snprintf(pbuf, len, "%s: %s", sensor_info_table[id].name, (char *)pdata->p); 161 | } 162 | 163 | return pbuf; 164 | } 165 | 166 | char *sensor_set_title(int index, char *pbuf, int len) 167 | { 168 | sensor_t *pdata = g_sensor_list + index; 169 | int id = pdata->id; 170 | snprintf(pbuf, len, "Set %s", sensor_info_table[id].name); 171 | 172 | return pbuf; 173 | } 174 | 175 | void sensor_set_update_callback(void (*pfunc)(void)) 176 | { 177 | p_sensor_changed_callback = pfunc; 178 | } 179 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/laudio.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "vmlog.h" 4 | #include "vmchset.h" 5 | #include "vmaudio.h" 6 | #include "vmaudio_play.h" 7 | #include "vmfs.h" 8 | #include "string.h" 9 | #include "vmstdlib.h" 10 | #include "laudio.h" 11 | 12 | 13 | VMINT8 m_path[256]; 14 | VMINT8 m_volume; 15 | VMINT8 m_drv; 16 | VMINT8 m_type; 17 | 18 | static int status_result = 0 ; 19 | 20 | static VMINT g_handle = -1; // The handle of play 21 | static VMINT g_interrupt_handle = 0; // The handle of interrupt 22 | 23 | 24 | void audio_play_callback(VM_AUDIO_HANDLE handle, VM_AUDIO_RESULT result, void* userdata) 25 | { 26 | int* res = (int*)userdata; 27 | 28 | * res = result; 29 | switch (result) 30 | { 31 | case VM_AUDIO_RESULT_END_OF_FILE: 32 | // When the end of file is reached, it needs to stop and close the handle 33 | vm_audio_play_stop(g_handle); 34 | vm_audio_play_close(g_handle); 35 | g_handle = -1; 36 | break; 37 | 38 | case VM_AUDIO_RESULT_INTERRUPT: 39 | // The playback is terminated by another application, for example an incoming call 40 | vm_audio_play_stop(g_handle); 41 | vm_audio_play_close(g_handle); 42 | //vm_audio_play_pause(g_handle); 43 | g_handle = -1; 44 | break; 45 | /* 46 | case VM_AUDIO_FAILED: 47 | break; 48 | 49 | case VM_AUDIO_SUCCEED: 50 | break; 51 | 52 | case VM_AUDIO_RESULT_STOP: 53 | break; 54 | 55 | case VM_AUDIO_RESULT_INTERRUPT_RESUME: 56 | vm_audio_play_resume(g_handle); 57 | break; 58 | */ 59 | default: 60 | break; 61 | } 62 | } 63 | 64 | VMUINT8 audioPlay(StorageEnum drv, VMINT8 *songName) 65 | { 66 | VMWCHAR path[256]; 67 | VMCHAR path_a[256]; 68 | vm_audio_play_parameters_t play_parameters; 69 | VM_AUDIO_VOLUME volume; 70 | 71 | strcpy((char*)m_path, songName); 72 | m_drv = drv; 73 | m_type = TRUE; 74 | 75 | if(m_drv == 0) 76 | { 77 | drv = vm_fs_get_internal_drive_letter(); 78 | } 79 | else 80 | { 81 | drv = vm_fs_get_removable_drive_letter(); 82 | } 83 | 84 | if(drv >= 0) 85 | { 86 | if(m_type) 87 | { 88 | sprintf(path_a,(const signed char*)"%c:\\%s", drv, (VMINT8*)m_path); 89 | vm_chset_ascii_to_ucs2(path, 256, path_a); 90 | } 91 | else 92 | { 93 | sprintf(path_a,(const signed char*)"%c:\\", drv); 94 | vm_chset_ascii_to_ucs2(path, 256, path_a); 95 | vm_wstr_concatenate(path, (VMWSTR)m_path); 96 | } 97 | } 98 | else 99 | { 100 | vm_log_info("AudioPlay get driver error"); 101 | return FALSE; 102 | } 103 | 104 | // set play parameters 105 | memset(&play_parameters, 0, sizeof(vm_audio_play_parameters_t)); 106 | play_parameters.filename = path; 107 | play_parameters.reserved = 0; // 108 | play_parameters.format = VM_AUDIO_FORMAT_MP3; // 109 | //play_parameters.output_path = VM_AUDIO_DEVICE_SPEAKER2; 110 | //play_parameters.output_path = VM_AUDIO_DEVICE_LOUDSPEAKER; 111 | play_parameters.output_path = VM_AUDIO_DEVICE_SPEAKER_BOTH; 112 | play_parameters.async_mode = 0; 113 | play_parameters.callback = audio_play_callback; 114 | play_parameters.user_data = &status_result; 115 | 116 | g_handle = vm_audio_play_open(&play_parameters); 117 | 118 | if(g_handle >= VM_OK) 119 | { 120 | vm_log_info("open success"); 121 | //*res = 0; 122 | } 123 | else 124 | { 125 | vm_log_info("open failed"); 126 | //*res = -1; 127 | return FALSE; 128 | } 129 | // start to play 130 | vm_audio_play_start(g_handle); 131 | // set volume 132 | // vm_audio_set_volume(VM_AUDIO_VOLUME_6); 133 | // register interrupt callback 134 | g_interrupt_handle = vm_audio_register_interrupt_callback(audio_play_callback,&status_result); 135 | } 136 | 137 | VMUINT8 audioPause(void* user_data) 138 | { 139 | if(g_handle >= 0) 140 | { 141 | vm_audio_play_pause(g_handle); 142 | return TRUE; 143 | } 144 | 145 | return FALSE; 146 | } 147 | 148 | VMUINT8 audioResume(void* user_data) 149 | { 150 | if(g_handle >= 0) 151 | { 152 | vm_audio_play_resume(g_handle); 153 | return TRUE; 154 | } 155 | return FALSE; 156 | } 157 | 158 | VMUINT8 audioStop(void* user_data) 159 | { 160 | if(g_handle >= 0) 161 | { 162 | vm_audio_play_stop(g_handle); 163 | vm_audio_play_close(g_handle); 164 | 165 | if(g_interrupt_handle!=0) 166 | { 167 | vm_audio_clear_interrupt_callback(g_interrupt_handle); 168 | } 169 | return TRUE; 170 | } 171 | return FALSE; 172 | } 173 | 174 | VMUINT8 audioSetVolume(VMUINT8 volData) 175 | { 176 | switch(volData) 177 | { 178 | case 0: 179 | vm_audio_set_volume(VM_AUDIO_VOLUME_0); 180 | break;; 181 | case 1: 182 | vm_audio_set_volume(VM_AUDIO_VOLUME_1); 183 | break; 184 | case 2: 185 | vm_audio_set_volume(VM_AUDIO_VOLUME_2); 186 | break; 187 | case 3: 188 | vm_audio_set_volume(VM_AUDIO_VOLUME_3); 189 | break; 190 | case 4: 191 | vm_audio_set_volume(VM_AUDIO_VOLUME_4); 192 | break; 193 | case 5: 194 | vm_audio_set_volume(VM_AUDIO_VOLUME_5); 195 | break; 196 | case 6: 197 | vm_audio_set_volume(VM_AUDIO_VOLUME_6); 198 | break; 199 | default: 200 | break; 201 | } 202 | return TRUE; 203 | } 204 | 205 | VMINT8 audioGetStatus(void* user_data) 206 | { 207 | return status_result; 208 | } 209 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/tp_goodix_gt9xx.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TP_GOODIX_GT9XX_H__ 3 | #define __TP_GOODIX_GT9XX_H__ 4 | 5 | #include "vmtype.h" 6 | #include "vmdrv_tp.h" 7 | 8 | 9 | #define CTP_SLAVE_ADDR 0xBA 10 | #define CTP_POWER_MODE_REG 0x8040 11 | #define CTP_FW_HEADER_SIZE 0 12 | #define CTP_VERSION_INFO_REG 0x8140 13 | #define CTP_MASTER_CODE_REG 0xC000 14 | #define CTP_FIRMWARE_SIZE (0x8000+CTP_FW_HEADER_SIZE) 15 | #define CTP_TOUCH_INFO_REG_BASE 0x814E 16 | #define CTP_POINT_INFO_REG_BASE 0x814F 17 | #define CTP_CONFIG_REG_BASE 0x8047 18 | #define CTP_FIRMWARE_VERSION 0x8147 19 | #define CTP_NVRAM_I2C_ADDRESS 0x5094 20 | #define CTP_NVRAM_OPERATION_SIZE 0x5096 21 | #define CTP_NVRAM_FILE_OFFSET 0x4196 22 | #define CTP_NVRAM_OPERATION_CHECKSUM 0x4194 23 | #define CTP_FLASH_POWER_OFF 0x4284 24 | 25 | #define CTP_SRAM_BANK 0x4048 26 | #define CTP_MEM_CD_EN 0x4049 27 | #define CTP_CACHE_EN 0x404B 28 | #define CTP_TMR0_EN 0x40B0 29 | #define CTP_SWRST_B0_ 0x4180 30 | #define CTP_CPU_SWRST_PULSE 0x4184 31 | #define CTP_BOOTCTL_B0_ 0x4190 32 | #define CTP_BOOT_OPT_B0_ 0x4218 33 | #define CTP_BOOT_CTL_ 0x5094 34 | #define CTP_ANA_RXADC_B0_ 0x4250 35 | #define CTP_RG_LDO_A18_PWD 0x426f 36 | #define CTP_RG_BG_PWD 0x426a 37 | #define CTP_RG_CLKGEN_PWD 0x4269 38 | #define CTP_RG_DMY 0x4282 39 | #define CTP_RG_OSC_CALIB 0x4268 40 | #define CTP_OSC_CK_SEL 0x4030 41 | 42 | #define CTP_HANDSHAKING_START_REG 0xFFF 43 | #define CTP_HANDSHAKING_END_REG 0x8000 44 | #define CTP_SOFT_RESET_MODE 0x01 45 | #define CTP_POINT_INFO_LEN 8 46 | #define TPD_MAX_POINTS 5 47 | #define MAX_TRANSACTION_LENGTH 8 48 | #define I2C_DEVICE_ADDRESS_LEN 2 49 | 50 | #define TPD_PROXIMITY_WORK_REG_BASE 0x920 51 | #define TPD_PROXIMITY_SAMPLE_REG 0xA88 52 | #define TPD_PROXIMITY_BASE_REG 0xAD8 53 | #define TPD_LARGE_OBJECT_DETECT_REG 0x71D 54 | 55 | #define _FW_TOTAL_PAGES 32 56 | #define _FW_FRAME_PAGES 16 57 | #define _DSP_TOTAL_PAGES 4 58 | #define _BOOTCODE_TOTAL_PAGES 32 59 | #define _FW_FRAME_BYTES (_FW_FRAME_PAGES*1024) 60 | #define _DSP_TOTAL_BYTES (_DSP_TOTAL_PAGES*1024) 61 | #define _BOOTCODE_TOTAL_BYTES (_BOOTCODE_TOTAL_PAGES*1024) 62 | 63 | #define CTP_STAT_NUMBER_TOUCH 0xF 64 | #define GPIO_CTP_INT_PIN gpio_ctp_eint_pin 65 | #define GPIO_CTP_SHUTDN_PIN gpio_ctp_reset_pin 66 | #define GPIO_CTP_EINT_NO 4 67 | #define CONFIG_LEN (186) 68 | 69 | //hotknot 70 | #define GTP_COMPATIBLE_MODE 0 //not use in FLASH series 71 | #ifdef __HOTKNOT_SUPPORT__ 72 | #define GTP_HOTKNOT_MODULE 1 //for HOTKNOT feature 73 | #else 74 | #define GTP_HOTKNOT_MODULE 0 //for HOTKNOT feature 75 | #endif 76 | #define GTP_AUTO_UPDATE_HOTKNOT 0 //for HOTKNOT update firmware in FS 77 | #define GTP_DEBUG_ARRAY_ON 1 78 | #define GTP_SUPPORT_I2C_DMA 1 79 | 80 | 81 | 82 | #define GTP_DEBUG_ON 1 83 | 84 | #define REG_2ND_CMD 0x8040 85 | #define REG_1ST_CMD 0x8046 86 | #define REG_LINK_MODE 0x81A8 87 | #define REG_PAIR_FLAG 0x81AA 88 | #define REG_XFE_STATE 0xAB10 89 | #define REG_NOTIFY_STATE 0xAB1F 90 | #define REG_SNDBUF_START 0xAC90 91 | #define REG_DATA_FRESH 0xAD91 92 | #define REG_RCVBUF_STATE 0xAE10 93 | #define REG_RCVBUF_START 0xAE12 94 | 95 | #define CMD_ENTER_SLAVE 0x20 96 | #define CMD_ENTER_MASTER 0x21 97 | #define CMD_ENTER_TRANSFER 0x22 98 | #define CMD_EXIT_SLAVE 0x28 99 | #define CMD_EXIT_MASTER 0x29 100 | #define CMD_EXIT_TRANSFER 0x2A 101 | 102 | #define MODE_TOUCH_ONLY 0x00 103 | #define MODE_PAIRED 0X55 104 | #define MODE_SLAVE 0x88 105 | #define MODE_MASTER 0x99 106 | #define MODE_SEND 0xAA 107 | #define MODE_RECEIVE 0xBB 108 | 109 | typedef enum 110 | { 111 | CHIP_TYPE_GT9 = 0, 112 | CHIP_TYPE_GT9F = 1, 113 | }CHIP_TYPE_T; 114 | 115 | 116 | //end 117 | typedef struct 118 | { 119 | VMUINT8 vendor_id_1; 120 | VMUINT8 vendor_id_2; 121 | VMUINT8 product_id_1; 122 | VMUINT8 product_id_2; 123 | VMUINT8 version_1; 124 | VMUINT8 version_2; 125 | } ctp_info_t; 126 | 127 | extern VM_DRV_TP_BOOL ctp_i2c_receive_ext(VMUINT8 ucDeviceAddr, VMUINT16 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 128 | extern VM_DRV_TP_BOOL ctp_i2c_send(VMUINT8 ucDeviceAddr, VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 129 | 130 | void tp_gt9xx_init(void); 131 | VM_DRV_TP_BOOL ctp_goodix_gt9xx_get_data(vm_drv_tp_multiple_event_t *tpes); 132 | 133 | #define CTP_I2C_read(a,b,c) ctp_i2c_receive_ext( CTP_SLAVE_ADDR, a, b, c) 134 | #define CTP_I2C_send(a,b,c) ctp_i2c_send_ext( CTP_SLAVE_ADDR, a, b, c) 135 | 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lstorage.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmlog.h" 3 | #include "vmfs.h" 4 | #include "vmchset.h" 5 | #include 6 | #include 7 | #include "lstorage.h" 8 | 9 | 10 | void file_create(const char* fileName) 11 | { 12 | VMCHAR filename[VM_FS_MAX_PATH_LENGTH] = {0}; 13 | VMWCHAR wfilename[VM_FS_MAX_PATH_LENGTH] = {0}; 14 | VM_FS_HANDLE filehandle = -1; 15 | 16 | sprintf((char*)filename, "%c:\\%s", vm_fs_get_internal_drive_letter(), fileName); 17 | vm_chset_ascii_to_ucs2(wfilename, sizeof(wfilename), filename); 18 | 19 | if((filehandle = vm_fs_open(wfilename, VM_FS_MODE_CREATE_ALWAYS_WRITE, TRUE)) < 0) 20 | { 21 | vm_log_info("Failed to create file: %s",filename); 22 | return; 23 | } 24 | vm_log_info("Success to create file: %s", filename); 25 | vm_fs_close(filehandle); 26 | } 27 | 28 | void file_open(const char* fileName) 29 | { 30 | VMCHAR filename[VM_FS_MAX_PATH_LENGTH] = {0}; 31 | VMWCHAR wfilename[VM_FS_MAX_PATH_LENGTH] = {0}; 32 | VM_FS_HANDLE filehandle = -1; 33 | 34 | sprintf((char*)filename, "%c:\\%s", vm_fs_get_internal_drive_letter(), fileName); 35 | vm_chset_ascii_to_ucs2(wfilename, sizeof(wfilename), filename); 36 | 37 | if((filehandle = vm_fs_open(wfilename, VM_FS_MODE_READ, TRUE)) < 0) 38 | { 39 | vm_log_info("Failed to open file: %s",filename); 40 | 41 | if((filehandle = vm_fs_open(wfilename, VM_FS_MODE_CREATE_ALWAYS_WRITE, TRUE)) < 0) 42 | { 43 | vm_log_info("Failed to create file: %s",filename); 44 | return; 45 | } 46 | 47 | vm_log_info("Success to create file: %s", filename); 48 | vm_fs_close(filehandle); 49 | return; 50 | } 51 | 52 | //vm_log_info("Success to open file: %s", filename); 53 | vm_fs_close(filehandle); 54 | } 55 | 56 | void file_write(const char* fileName, const char* strBuf, long pos) 57 | { 58 | VMCHAR filename[VM_FS_MAX_PATH_LENGTH] = {0}; 59 | VMWCHAR wfilename[VM_FS_MAX_PATH_LENGTH] = {0}; 60 | VM_FS_HANDLE filehandle = -1; 61 | VMUINT writelen = 0; 62 | VMINT ret = 0; 63 | 64 | sprintf((char*)filename, "%c:\\%s", vm_fs_get_internal_drive_letter(), fileName); 65 | vm_chset_ascii_to_ucs2(wfilename, sizeof(wfilename), filename); 66 | 67 | // write file 68 | if((filehandle = vm_fs_open(wfilename, VM_FS_MODE_WRITE, TRUE)) < 0) 69 | { 70 | vm_log_info("Write failed to open file: %s",filename); 71 | return; 72 | } 73 | vm_log_info("Write success to open file: %s", filename); 74 | 75 | vm_fs_seek(filehandle, pos, VM_FS_BASE_END); 76 | 77 | ret = vm_fs_write(filehandle, (void*)strBuf, strlen(strBuf), &writelen); 78 | if(ret < 0) 79 | { 80 | vm_log_info("Failed to write file"); 81 | return; 82 | } 83 | vm_log_info("Success to write file: %s", filename); 84 | vm_fs_close(filehandle); 85 | } 86 | 87 | void file_delete(const char* fileName) 88 | { 89 | VMCHAR filename[VM_FS_MAX_PATH_LENGTH] = {0}; 90 | VMWCHAR wfilename[VM_FS_MAX_PATH_LENGTH] = {0}; 91 | VMINT ret = 0; 92 | 93 | sprintf((char*)filename, "%c:\\%s", vm_fs_get_internal_drive_letter(), fileName); 94 | vm_chset_ascii_to_ucs2(wfilename, sizeof(wfilename), filename); 95 | 96 | ret = vm_fs_delete(wfilename); 97 | if(ret == 0) 98 | { 99 | vm_log_info("Success to delete file: %s",filename); 100 | } 101 | else 102 | { 103 | vm_log_info("Failed to delete file: %s",filename); 104 | } 105 | } 106 | 107 | void file_read(const char* fileName, char* strBuf, unsigned int nByte, long pos) 108 | { 109 | VMCHAR filename[VM_FS_MAX_PATH_LENGTH] = {0}; 110 | VMWCHAR wfilename[VM_FS_MAX_PATH_LENGTH] = {0}; 111 | VM_FS_HANDLE filehandle = -1; 112 | VMUINT readlen = 0; 113 | VMINT ret = 0; 114 | 115 | sprintf((char*)filename, "%c:\\%s", vm_fs_get_internal_drive_letter(), fileName); 116 | vm_chset_ascii_to_ucs2(wfilename, sizeof(wfilename), filename); 117 | 118 | if((filehandle = vm_fs_open(wfilename, VM_FS_MODE_READ, TRUE)) < 0) 119 | { 120 | vm_log_info("Failed to open file: %s",filename); 121 | return; 122 | } 123 | vm_log_info("Success to open file: %s", filename); 124 | 125 | ret = vm_fs_seek(filehandle, pos, VM_FS_BASE_BEGINNING); 126 | if (ret < 0) 127 | { 128 | vm_log_info("Failed to seek the file."); 129 | vm_fs_close(filehandle); 130 | return; 131 | } 132 | 133 | vm_log_info("Success to seek the file."); 134 | 135 | ret = vm_fs_read(filehandle, (void*)strBuf, nByte, &readlen); 136 | if (ret < 0) 137 | { 138 | vm_log_info("Failed to read the file."); 139 | vm_fs_close(filehandle); 140 | return; 141 | } 142 | 143 | vm_log_info("Success to read the file."); 144 | vm_fs_close(filehandle); 145 | } 146 | 147 | void file_size(const char* fileName, unsigned long* size) 148 | { 149 | VMCHAR filename[VM_FS_MAX_PATH_LENGTH] = {0}; 150 | VMWCHAR wfilename[VM_FS_MAX_PATH_LENGTH] = {0}; 151 | VM_FS_HANDLE filehandle = -1; 152 | 153 | sprintf((char*)filename, "%c:\\%s", vm_fs_get_internal_drive_letter(), fileName); 154 | vm_chset_ascii_to_ucs2(wfilename, sizeof(wfilename), filename); 155 | 156 | if((filehandle = vm_fs_open(wfilename, VM_FS_MODE_READ, TRUE)) < 0) 157 | { 158 | vm_log_info("Failed to open file: %s",filename); 159 | return; 160 | } 161 | 162 | //vm_log_info("Success to open file: %s", filename); 163 | vm_fs_get_size(filehandle, (VMUINT*)size); 164 | vm_fs_close(filehandle); 165 | } 166 | 167 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/music.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmtype.h" 3 | #include "ugui.h" 4 | #include "laudio.h" 5 | #include "vmfs.h" 6 | #include "vmchset.h" 7 | 8 | UG_WINDOW g_music_window; 9 | char g_music_filename[4][32] = {0,}; 10 | int g_music_filename_selected = -1; 11 | uint32_t *g_music_data_ptr = NULL; 12 | 13 | void music_window_show(uint32_t *pdata) 14 | { 15 | g_music_data_ptr = pdata; 16 | UG_WindowShow(&g_music_window); 17 | } 18 | 19 | void music_do_action(uint32_t *pdata) 20 | { 21 | char *music = "ringtone.mp3"; 22 | unsigned index = *pdata; 23 | if (index < 4 && g_music_filename[index][0] != '\0') { 24 | music = g_music_filename[index]; 25 | } 26 | audioPlay(storageFlash, music); 27 | } 28 | 29 | void music_window_callback(UG_MESSAGE *msg) 30 | { 31 | if (msg->type == MSG_TYPE_OBJECT) { 32 | if (msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 33 | int index; 34 | switch (msg->sub_id) { 35 | case 0: // back 36 | UG_WindowShow(UG_GetLastWindow()); 37 | g_music_data_ptr = NULL; 38 | break; 39 | case 1: // stop 40 | audioStop(NULL); 41 | break; 42 | case 2: // play 43 | //audioPlay(storageFlash, "ringtone.mp3"); 44 | audioPlay(storageFlash, g_music_filename[g_music_filename_selected]); 45 | break; 46 | case 3: 47 | case 4: 48 | case 5: 49 | case 6: 50 | index = msg->sub_id - 3; 51 | if (g_music_filename[index][0] != 0) { 52 | if (g_music_filename_selected >= 0) { 53 | UG_ButtonSetForeColor(&g_music_window, 3 + g_music_filename_selected, C_WHITE); 54 | UG_ButtonSetBackColor(&g_music_window, 3 + g_music_filename_selected, C_BUTTON_BC); 55 | } 56 | 57 | UG_ButtonSetForeColor(&g_music_window, 3 + index, C_BUTTON_BC); 58 | UG_ButtonSetBackColor(&g_music_window, 3 + index, C_WHITE); 59 | 60 | g_music_filename_selected = index; 61 | if (g_music_data_ptr) { 62 | *g_music_data_ptr = index; 63 | } 64 | } 65 | break; 66 | } 67 | 68 | } 69 | } 70 | } 71 | 72 | void music_window_create(void) 73 | { 74 | static UG_BUTTON buttons[8]; 75 | static UG_OBJECT objects[8]; 76 | char *icons[] = { "1", "D", "C" }; // back, stop, play 77 | int i = 0; 78 | int id = 0; 79 | 80 | UG_WindowCreate(&g_music_window, objects, 81 | sizeof(objects) / sizeof(*objects), music_window_callback); 82 | UG_WindowSetStyle(&g_music_window, WND_STYLE_2D); 83 | 84 | for (i = 0; i < 3; i++) { 85 | UG_ButtonCreate(&g_music_window, buttons+ i, i, 80 * i, 86 | 200, 80 * i + 80 - 1, 239); 87 | UG_ButtonSetFont(&g_music_window, i , &FONT_ICON24); 88 | UG_ButtonSetText(&g_music_window, i, icons[i]); 89 | UG_ButtonSetStyle(&g_music_window, i, 90 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 91 | 92 | } 93 | 94 | { 95 | vm_fs_info_t fs_info; 96 | VM_FS_HANDLE handle; 97 | char search_pattern[32]; 98 | VMWCHAR search_pattern_w[32]; 99 | 100 | snprintf(search_pattern, sizeof(search_pattern), "%c:\\*.mp3", vm_fs_get_internal_drive_letter()); 101 | vm_chset_ascii_to_ucs2(search_pattern_w, sizeof(search_pattern_w), search_pattern); 102 | 103 | handle = vm_fs_find_first(search_pattern_w, &fs_info); 104 | if (handle > 0) { 105 | for (i = 0; i < 4; i++) { 106 | vm_chset_ucs2_to_ascii(g_music_filename[i], sizeof(g_music_filename[i]), fs_info.filename); 107 | 108 | if (vm_fs_find_next(handle, &fs_info) != VM_FS_SUCCESS) { 109 | break; 110 | } 111 | } 112 | vm_fs_find_close(handle); 113 | } 114 | } 115 | 116 | for (i = 0; i < 4; i++) { 117 | id = 3 + i; 118 | UG_ButtonCreate(&g_music_window, buttons + id, id, 0, 119 | 40 * i + 40, 239, 40 * i + 80 - 1); 120 | UG_ButtonSetFont(&g_music_window, id, &FONT_SIZE20); 121 | UG_ButtonSetText(&g_music_window, id, g_music_filename[i]); 122 | UG_ButtonSetStyle(&g_music_window, id, 123 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 124 | 125 | } 126 | 127 | if (g_music_filename[0][0] != 0) { 128 | g_music_filename_selected = 0; 129 | 130 | UG_ButtonSetForeColor(&g_music_window, 3, C_BUTTON_BC); 131 | UG_ButtonSetBackColor(&g_music_window, 3, C_WHITE); 132 | } 133 | 134 | 135 | 136 | id = 7; 137 | UG_ButtonCreate(&g_music_window, buttons + id, id, 0, 0, 239, 39); 138 | UG_ButtonSetFont(&g_music_window, id, &FONT_SIZE20); 139 | UG_ButtonSetText(&g_music_window, id, "Music"); 140 | UG_ButtonSetStyle(&g_music_window, id, 141 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 142 | UG_ButtonSetBackColor(&g_music_window, id, 0x000000); 143 | } 144 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ldlci2cV2.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmdcl.h" 3 | #include "vmlog.h" 4 | #include "vmdcl_gpio.h" 5 | #include "vmdcl_i2c.h" 6 | #include "vmdatetime.h" 7 | #include "ldlci2cV2.h" 8 | #include "string.h" 9 | 10 | 11 | VMUINT8 dlc_i2c_configure_done = FALSE; 12 | 13 | VM_DCL_HANDLE dlc_i2c_handle; 14 | 15 | 16 | 17 | void dlc_i2c_configure(VMUINT32 slave_addr, VMUINT32 speed) 18 | { 19 | vm_dcl_i2c_control_config_t conf_data; 20 | 21 | if(!dlc_i2c_configure_done) 22 | { 23 | dlc_i2c_handle = vm_dcl_open(VM_DCL_I2C, 0); 24 | } 25 | 26 | conf_data.reserved_0 = (VM_DCL_I2C_OWNER)0; 27 | conf_data.transaction_mode = VM_DCL_I2C_TRANSACTION_FAST_MODE; 28 | conf_data.get_handle_wait = TRUE; 29 | conf_data.reserved_1 = 0; 30 | conf_data.delay_length = 0; 31 | conf_data.slave_address = (slave_addr << 1); 32 | 33 | conf_data.fast_mode_speed = speed; 34 | conf_data.high_mode_speed = 0; 35 | vm_dcl_control(dlc_i2c_handle,VM_DCL_I2C_CMD_CONFIG,(void *)&conf_data); 36 | 37 | dlc_i2c_configure_done = TRUE; 38 | } 39 | 40 | VMUINT8 dlc_i2c_send_byte(VMUINT8 ucData) 41 | { 42 | VMINT16 i; 43 | VMINT8 ret; 44 | VMUINT8 ucMask; 45 | VM_DCL_STATUS status = VM_DCL_STATUS_FAIL; 46 | vm_dcl_gpio_control_level_status_t sda_read; 47 | vm_dcl_i2c_control_continue_write_t write; 48 | 49 | if(dlc_i2c_configure_done) 50 | { 51 | write.data_ptr = &ucData; 52 | write.data_length = 1; 53 | write.transfer_number = 1; 54 | status = vm_dcl_control(dlc_i2c_handle, VM_DCL_I2C_CMD_CONT_WRITE, (void *)&write); 55 | } 56 | 57 | ret = (status == VM_DCL_STATUS_OK)?TRUE:FALSE; 58 | 59 | return ret; 60 | } 61 | 62 | VMUINT8 dlc_i2c_receive_byte(VMUINT8 bAck) 63 | { 64 | VMUINT8 ucRet = 0; 65 | VMINT16 i; 66 | vm_dcl_i2c_control_continue_read_t read; 67 | vm_dcl_gpio_control_level_status_t sda_read; 68 | VM_DCL_STATUS status; 69 | 70 | if(dlc_i2c_configure_done) 71 | { 72 | read.data_ptr = &ucRet; 73 | read.data_length = 1; 74 | read.transfer_number = 1; 75 | status = vm_dcl_control(dlc_i2c_handle, VM_DCL_I2C_CMD_CONT_READ, (void *)&read); 76 | if(status != VM_DCL_STATUS_OK)return FALSE; 77 | } 78 | 79 | return ucRet; 80 | } 81 | 82 | VMUINT8 dlc_i2c_send(VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength) 83 | { 84 | VMUINT32 i; 85 | VMUINT8 write_buf[9]; 86 | VMUINT8 bRet = TRUE; 87 | vm_dcl_i2c_control_continue_write_t write; 88 | VM_DCL_STATUS status; 89 | 90 | if(dlc_i2c_configure_done) 91 | { 92 | write_buf[0] = ucBufferIndex; 93 | for(i=0;i> 8 )& 0xFF; 123 | VMUINT8 addr_l = ucBufferIndex&0xFF; 124 | VMUINT32 offset = 0; 125 | VMUINT8 pkt_len; 126 | 127 | if(dlc_i2c_configure_done) 128 | { 129 | while ( offset <= unDataLength ) 130 | { 131 | write_buf[0] = ((ucBufferIndex + offset)>>8)&0xFF; 132 | write_buf[1] = (ucBufferIndex + offset)&0xFF; 133 | if ( unDataLength - offset > 6 ) 134 | { 135 | pkt_len = 6; 136 | } 137 | else 138 | { 139 | pkt_len = unDataLength - offset; 140 | } 141 | memcpy( &write_buf[2], &pucData[offset], pkt_len ); 142 | offset += pkt_len; 143 | write.data_ptr = write_buf; 144 | write.data_length = pkt_len+2; 145 | write.transfer_number = 1; 146 | status = vm_dcl_control(dlc_i2c_handle, VM_DCL_I2C_CMD_CONT_WRITE, (void *)&write); 147 | 148 | if(status != VM_DCL_STATUS_OK)return FALSE; 149 | if ( offset == unDataLength ) break; 150 | } 151 | } 152 | 153 | return bRet; 154 | } 155 | 156 | VMUINT8 dlc_i2c_receive(VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength) 157 | { 158 | VMUINT32 i; 159 | VM_DCL_STATUS dcl_i2c_ret; 160 | VMUINT8 bRet = TRUE; 161 | vm_dcl_i2c_control_write_and_read_t write_read; 162 | 163 | if(dlc_i2c_configure_done) 164 | { 165 | write_read.in_data_ptr = pucData; 166 | write_read.in_data_length = unDataLength; 167 | write_read.out_data_ptr = &ucBufferIndex; 168 | write_read.out_data_length = 1; 169 | dcl_i2c_ret = vm_dcl_control(dlc_i2c_handle, VM_DCL_I2C_CMD_WRITE_AND_READ, (void *)&write_read); 170 | if(dcl_i2c_ret != VM_DCL_STATUS_OK) 171 | { 172 | bRet = FALSE; 173 | } 174 | } 175 | 176 | return bRet; 177 | } 178 | 179 | VMUINT8 dlc_i2c_receive_ext(VMUINT16 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength) 180 | { 181 | VMUINT32 i; 182 | VMUINT8 bRet = TRUE; 183 | vm_dcl_i2c_control_write_and_read_t write_read; 184 | VMUINT8 write_buf[2]; 185 | VMUINT16 reg_addr = ucBufferIndex; 186 | VMUINT32 offset = 0; 187 | VMUINT8 pkt_len; 188 | VMUINT8 addr_h = ( ucBufferIndex >> 8 )& 0xFF; 189 | VMUINT8 addr_l = ucBufferIndex&0xFF; 190 | 191 | if(dlc_i2c_configure_done) 192 | { 193 | while ( offset < unDataLength ) 194 | { 195 | write_buf[0] = ( reg_addr >> 8 )& 0xFF; 196 | write_buf[1] = reg_addr&0xFF; 197 | if ( unDataLength - offset > 8 ) 198 | { 199 | pkt_len = 8; 200 | } 201 | else 202 | { 203 | pkt_len = unDataLength - offset; 204 | } 205 | write_read.in_data_ptr = pucData + offset; 206 | write_read.in_data_length = pkt_len; 207 | write_read.out_data_ptr = write_buf; 208 | write_read.out_data_length = 2; 209 | vm_dcl_control(dlc_i2c_handle, VM_DCL_I2C_CMD_WRITE_AND_READ, (void *)&write_read); 210 | offset += pkt_len; 211 | reg_addr = ucBufferIndex + offset; 212 | } 213 | } 214 | 215 | return bRet; 216 | } 217 | 218 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ldlcgpio.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmtype.h" 3 | #include "vmsystem.h" 4 | #include "vmthread.h" 5 | #include "vmlog.h" 6 | #include "vmdcl.h" 7 | #include "vmdcl_gpio.h" 8 | #include "vmdcl_adc.h" 9 | #include "vmdatetime.h" 10 | #include "vmboard.h" 11 | #include "ldlcgpio.h" 12 | 13 | 14 | static VM_DCL_HANDLE g_adc_handle = VM_DCL_HANDLE_INVALID; 15 | static VMINT32 g_adc_result = 0; 16 | 17 | 18 | void gpio_delay_ms(VMUINT32 millisecs) 19 | { 20 | VMUINT32 timeStop; 21 | VMUINT32 timeStart; 22 | VMUINT32 Freq = 0; 23 | volatile VMUINT32 i; 24 | millisecs = millisecs*1000; 25 | 26 | timeStart = vm_time_ust_get_count(); 27 | while( Freq < millisecs) 28 | { 29 | for(i=0;i<5000;i++){} 30 | timeStop = vm_time_ust_get_count(); 31 | Freq = timeStop - timeStart + 1; 32 | } 33 | } 34 | 35 | 36 | VMINT8 pinMode(VMUINT8 ulPin,VMUINT8 ulMode) 37 | { 38 | VM_DCL_HANDLE gpio_handle; 39 | gpio_handle = vm_dcl_open(VM_DCL_GPIO, ulPin); 40 | 41 | if(gpio_handle != VM_DCL_HANDLE_INVALID) 42 | { 43 | switch(ulMode) 44 | { 45 | case INPUT: 46 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL); 47 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_IN, NULL); 48 | break; 49 | 50 | case OUTPUT: 51 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL); 52 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_OUT, NULL); 53 | break; 54 | 55 | case INPUT_PULLUP: 56 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL); 57 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_IN, NULL); 58 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_ENABLE_PULL, NULL); 59 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_PULL_HIGH, NULL); 60 | break; 61 | 62 | case INPUT_PULLDN: 63 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL); 64 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_IN, NULL); 65 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_ENABLE_PULL, NULL); 66 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_SET_PULL_LOW, NULL); 67 | break; 68 | 69 | default: 70 | break; 71 | } 72 | } 73 | else 74 | { 75 | vm_log_info("gpio set pin mode fail"); 76 | return -1; 77 | } 78 | 79 | vm_dcl_close(gpio_handle); 80 | return TRUE; 81 | } 82 | 83 | VMINT8 digitalWrite(VMUINT8 ulPin,VMUINT8 ulData) 84 | { 85 | VM_DCL_HANDLE gpio_handle; 86 | gpio_handle = vm_dcl_open(VM_DCL_GPIO, ulPin); 87 | 88 | if(gpio_handle != VM_DCL_HANDLE_INVALID) 89 | { 90 | if(ulData == LOW) 91 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_WRITE_LOW, NULL); 92 | else if(ulData == HIGH) 93 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_WRITE_HIGH, NULL); 94 | } 95 | else 96 | { 97 | vm_log_info("gpio write pin fail"); 98 | return -1; 99 | } 100 | 101 | vm_dcl_close(gpio_handle); 102 | return TRUE; 103 | } 104 | 105 | VMINT8 digitalRead(VMUINT8 ulPin) 106 | { 107 | VM_DCL_HANDLE gpio_handle; 108 | vm_dcl_gpio_control_level_status_t data; 109 | VMUINT8 ret; 110 | 111 | gpio_handle = vm_dcl_open(VM_DCL_GPIO, ulPin); 112 | 113 | if(gpio_handle != VM_DCL_HANDLE_INVALID) 114 | { 115 | vm_dcl_control(gpio_handle, VM_DCL_GPIO_COMMAND_READ, (void*)&data); 116 | 117 | if (data.level_status == 1)ret = HIGH; 118 | else ret = LOW; 119 | } 120 | else 121 | { 122 | vm_log_info("gpio read pin fail"); 123 | return -1; 124 | } 125 | 126 | vm_dcl_close(gpio_handle); 127 | return ret; 128 | } 129 | 130 | void adc_callback(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle) 131 | { 132 | vm_dcl_callback_data_t *data; 133 | vm_dcl_adc_measure_done_confirm_t * result; 134 | vm_dcl_adc_control_send_stop_t stop_data; 135 | VMINT status = 0; 136 | 137 | if(parameter!=NULL) 138 | { 139 | data = ( vm_dcl_callback_data_t*)parameter; 140 | result = (vm_dcl_adc_measure_done_confirm_t *)(data->local_parameters); 141 | 142 | if( result != NULL ) 143 | { 144 | double *p; 145 | 146 | p =(double*)&(result->value); 147 | g_adc_result = (unsigned int)*p; 148 | vm_log_info("get adc data is %d",g_adc_result); 149 | } 150 | } 151 | 152 | // Stop ADC 153 | stop_data.owner_id = vm_dcl_get_owner_id(); 154 | status = vm_dcl_control(g_adc_handle,VM_DCL_ADC_COMMAND_SEND_STOP,(void *)&stop_data); 155 | 156 | vm_dcl_close(g_adc_handle); 157 | } 158 | 159 | VMINT32 analogRead(VMUINT8 ulPin) 160 | { 161 | vm_dcl_adc_control_create_object_t obj_data; 162 | VMINT status = 0 , i; 163 | vm_dcl_adc_control_send_start_t start_data; 164 | 165 | if(ulPin > 3)// for ADC0 ADC1 ADC2 ADC3 166 | { 167 | vm_log_info("ADC pin number is error"); 168 | return -1; 169 | } 170 | 171 | vm_dcl_close(g_adc_handle); 172 | 173 | g_adc_handle = vm_dcl_open(VM_DCL_GPIO, ulPin); 174 | 175 | vm_dcl_control(g_adc_handle,VM_DCL_GPIO_COMMAND_SET_MODE_2,NULL); 176 | vm_dcl_close(g_adc_handle); 177 | 178 | // Open ADC device 179 | g_adc_handle = vm_dcl_open(VM_DCL_ADC,0); 180 | // register ADC result callback 181 | status = vm_dcl_register_callback(g_adc_handle, VM_DCL_ADC_GET_RESULT ,(vm_dcl_callback)adc_callback, (void *)NULL); 182 | 183 | // Indicate to the ADC module driver to notify the result. 184 | obj_data.owner_id = vm_dcl_get_owner_id(); 185 | // Set physical ADC channel which should be measured. 186 | obj_data.channel = PIN2CHANNEL(ulPin); 187 | // Set measurement period, the unit is in ticks. 188 | obj_data.period = 1; 189 | // Measurement count. 190 | obj_data.evaluate_count = 1; 191 | // Whether to send message to owner module or not. 192 | obj_data.send_message_primitive = 1; 193 | 194 | // setup ADC object 195 | status = vm_dcl_control(g_adc_handle,VM_DCL_ADC_COMMAND_CREATE_OBJECT,(void *)&obj_data); 196 | 197 | // start ADC 198 | start_data.owner_id = vm_dcl_get_owner_id(); 199 | status = vm_dcl_control(g_adc_handle,VM_DCL_ADC_COMMAND_SEND_START,(void *)&start_data); 200 | 201 | return g_adc_result; 202 | } 203 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ifttt.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "ifttt.h" 4 | #include "sensor.h" 5 | #include "actuator.h" 6 | #include 7 | 8 | ifttt_t g_ifttt_list[IFTTT_MAX_NUMBER] = {0,}; 9 | ifttt_t *g_ifttt_last = g_ifttt_list; 10 | int g_ifttt_number = 0; 11 | char g_ifttt_description_string[64]; 12 | 13 | void ifttt_check() 14 | { 15 | int i; 16 | int condition_mask; 17 | int condition_index; 18 | int action_mask; 19 | int action_index; 20 | int result; 21 | ifttt_t *ptr = g_ifttt_last; 22 | for (i = 0; i < g_ifttt_number; i++) { 23 | result = 0; 24 | condition_index = 0; 25 | condition_mask = ptr->condition_mask; 26 | while (condition_mask) { 27 | if (condition_mask & 1) { 28 | if (condition_check(condition_index)) { 29 | result++; 30 | } else { 31 | result -= 32; // make sure that result < 0 32 | } 33 | } 34 | condition_mask >>= 1; 35 | condition_index++; 36 | } 37 | 38 | if (result > 0) { 39 | if (!ptr->last) { 40 | action_index = 0; 41 | action_mask = ptr->action_mask; 42 | while (action_mask) { 43 | if (action_mask & 1) { 44 | action_exec(action_index); 45 | } 46 | action_mask >>= 1; 47 | action_index++; 48 | } 49 | 50 | ptr->last = 1; 51 | } 52 | } else { 53 | ptr->last = 0; 54 | } 55 | 56 | ptr = ptr->prev; 57 | } 58 | } 59 | 60 | int ifttt_add(int8_t *condition_index_map, int8_t *action_index_map) 61 | { 62 | int i; 63 | uint32_t conditions = 0; 64 | uint32_t actions = 0; 65 | for (i = 0; i < IFTTT_MAX_NUMBER; i++) { 66 | if (g_ifttt_list[i].condition_mask == 0) { 67 | break; 68 | } 69 | } 70 | 71 | if (i >= IFTTT_MAX_NUMBER) { 72 | return -1; 73 | } 74 | 75 | g_ifttt_list[i].prev = g_ifttt_last; 76 | g_ifttt_last = &g_ifttt_list[i]; 77 | 78 | g_ifttt_last->name[0] = 0; 79 | for (i = 0; i < SENSOR_MAX_NUMBER; i++) { 80 | int condition_index = condition_index_map[i]; 81 | if (condition_index != -1) { 82 | if (!conditions){ 83 | strcat(g_ifttt_last->name, sensor_get_name(i)); 84 | } else { 85 | strcat(g_ifttt_last->name, "&"); 86 | strcat(g_ifttt_last->name, sensor_get_name(i)); 87 | } 88 | conditions |= (uint32_t)1 << condition_index_map[i]; 89 | } 90 | } 91 | 92 | if (conditions == 0) { 93 | return -1; 94 | } 95 | 96 | strcat(g_ifttt_last->name, " >> "); 97 | for (i = 0; i < ACTUATOR_MAX_NUMBER; i++) { 98 | int action_index = action_index_map[i]; 99 | if (action_index != -1) { 100 | if (!actions) { 101 | strcat(g_ifttt_last->name, actuator_get_name(i)); 102 | } else { 103 | strcat(g_ifttt_last->name, "&"); 104 | strcat(g_ifttt_last->name, actuator_get_name(i)); 105 | } 106 | actions |= (uint32_t)1 << action_index_map[i]; 107 | } 108 | } 109 | 110 | if (actions == 0) { 111 | return -1; 112 | } 113 | 114 | g_ifttt_last->condition_mask = conditions; 115 | g_ifttt_last->action_mask = actions; 116 | g_ifttt_last->last = 0; 117 | g_ifttt_number++; 118 | 119 | return 0; 120 | } 121 | 122 | void ifttt_remove(int index) 123 | { 124 | ifttt_t **pptr; 125 | ifttt_t *p_remove_item; 126 | int n; 127 | int i; 128 | 129 | if (index >= g_ifttt_number) { 130 | return; 131 | } 132 | 133 | g_ifttt_number--; 134 | 135 | n = g_ifttt_number - index; 136 | pptr = &g_ifttt_last; 137 | p_remove_item = g_ifttt_last; 138 | for (i = 0; i < n; i++) { 139 | pptr = &(p_remove_item->prev); 140 | p_remove_item = p_remove_item->prev; 141 | } 142 | *pptr = p_remove_item->prev; 143 | p_remove_item->prev = 0; 144 | p_remove_item->condition_mask = 0; 145 | } 146 | 147 | ifttt_t *ifttt_get(int index) 148 | { 149 | int n = g_ifttt_number - index - 1; 150 | ifttt_t *ptr; 151 | int i; 152 | 153 | ptr = g_ifttt_last; 154 | for (i = 0; i < n; i++) { 155 | ptr = ptr->prev; 156 | } 157 | 158 | return ptr; 159 | } 160 | 161 | int ifttt_get_number() 162 | { 163 | return g_ifttt_number; 164 | } 165 | 166 | char *ifttt_get_name(int index) 167 | { 168 | int n = g_ifttt_number - index - 1; 169 | int i; 170 | ifttt_t *ptr = g_ifttt_last; 171 | 172 | for (i = 0; i < n; i++) { 173 | ptr = ptr->prev; 174 | } 175 | return ptr->name; 176 | } 177 | 178 | char *ifttt_get_description(int index) 179 | { 180 | uint32_t condition_mask; 181 | uint32_t action_mask; 182 | int i; 183 | int conditions = 0; 184 | int actions = 0; 185 | ifttt_t *ptr = ifttt_get(index); 186 | 187 | condition_mask = ptr->condition_mask; 188 | g_ifttt_description_string[0] = '\0'; 189 | i = 0; 190 | strcat(g_ifttt_description_string, "if "); 191 | while (condition_mask) { 192 | if (condition_mask & 1) { 193 | int len = strlen(g_ifttt_description_string); 194 | if (conditions > 0) { 195 | strcat(g_ifttt_description_string, " & "); 196 | len += 3; 197 | } 198 | condition_to_string(i, g_ifttt_description_string + len, sizeof(g_ifttt_description_string) - len); 199 | conditions++; 200 | } 201 | 202 | condition_mask >>= 1; 203 | i++; 204 | } 205 | 206 | action_mask = ptr->action_mask; 207 | i = 0; 208 | strcat(g_ifttt_description_string, " then "); 209 | while (action_mask) { 210 | if (action_mask & 1) { 211 | int len = strlen(g_ifttt_description_string); 212 | if (actions > 0) { 213 | strcat(g_ifttt_description_string, " & "); 214 | len += 3; 215 | } 216 | action_to_string(i, g_ifttt_description_string + len, sizeof(g_ifttt_description_string) - len); 217 | actions++; 218 | } 219 | 220 | action_mask >>= 1; 221 | i++; 222 | } 223 | 224 | return g_ifttt_description_string; 225 | } 226 | 227 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/gui_glue.c: -------------------------------------------------------------------------------- 1 | #include "ugui.h" 2 | #include "vmgraphic.h" 3 | #include "vmtimer.h" 4 | #include "vmlog.h" 5 | #include "vmtouch.h" 6 | #include "vmdcl.h" 7 | #include "string.h" 8 | 9 | vm_graphic_frame_t g_frame; 10 | vm_graphic_frame_t g_rotated_frame; 11 | const vm_graphic_frame_t* g_frame_blt_group[1]; 12 | 13 | UG_GUI g_gui; 14 | uint8_t g_gui_changed = 0; 15 | UG_COLOR g_gui_last_color = 0xFFFFFFFF; 16 | 17 | const UG_FONT FONT_SIZE20 = {(unsigned char*)0,FONT_TYPE_1BPP,12,20,0,255,NULL}; 18 | const UG_FONT FONT_SIZE40 = {(unsigned char*)0,FONT_TYPE_1BPP,24,40,0,255,NULL}; 19 | 20 | /* GUI update timer */ 21 | VM_TIMER_ID_PRECISE g_timer_id; 22 | 23 | extern void time_update_callback(void); 24 | extern int screen_suspend(void); 25 | extern void screen_resume(void); 26 | 27 | 28 | void gui_draw_font( char chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc, const UG_FONT* font) 29 | { 30 | char str[2] = {0, 0}; 31 | VMWCHAR s[4]; /* string's buffer */ 32 | VMUINT32 size; 33 | vm_graphic_color_argb_t color; /* use to set screen and text color */ 34 | 35 | uint16_t height = font->char_height; 36 | 37 | str[0] = chr; 38 | vm_chset_ascii_to_ucs2(s, 4, str); 39 | 40 | /* set color and draw text*/ 41 | if (g_gui_last_color != fc) { 42 | vm_graphic_color_argb_t color; 43 | 44 | color.a = (uint8_t)(fc >> 24); 45 | color.r = (uint8_t)(fc >> 16); 46 | color.g = (uint8_t)(fc >> 8); 47 | color.b = (uint8_t) fc; 48 | 49 | vm_graphic_set_color(color); 50 | g_gui_last_color = fc; 51 | } 52 | vm_graphic_set_font_size(height); 53 | vm_graphic_draw_text_by_baseline(&g_frame, x + 1, y + height, s, 0); 54 | 55 | g_gui_changed = 1; 56 | } 57 | 58 | void gui_change_color(UG_COLOR c) 59 | { 60 | if (g_gui_last_color != c) { 61 | vm_graphic_color_argb_t color; 62 | color.a = (uint8_t)(c >> 24); 63 | color.r = (uint8_t)(c >> 16); 64 | color.g = (uint8_t)(c >> 8); 65 | color.b = (uint8_t) c; 66 | vm_graphic_set_color(color); 67 | g_gui_last_color = c; 68 | } 69 | } 70 | 71 | static void gui_draw_point(UG_S16 x, UG_S16 y, UG_COLOR c) 72 | { 73 | #if 0 74 | if (g_gui_last_color != c) { 75 | vm_graphic_color_argb_t color; 76 | color.a = (uint8_t)(c >> 24); 77 | color.r = (uint8_t)(c >> 16); 78 | color.g = (uint8_t)(c >> 8); 79 | color.b = (uint8_t) c; 80 | vm_graphic_set_color(color); 81 | g_gui_last_color = c; 82 | } 83 | vm_graphic_draw_point(&g_frame, x, y); 84 | #else 85 | uint16_t *pbuf = (uint16_t *)g_frame.buffer; 86 | pbuf += y * 240 + x; 87 | *pbuf = ((c >> 8) & (0x1F << 11)) | ((c >> 5) & (0x3F << 5)) | ((c >> 3) & 0x1F); 88 | #endif 89 | 90 | g_gui_changed = 1; 91 | } 92 | 93 | static UG_RESULT gui_draw_line(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, 94 | UG_COLOR c) 95 | { 96 | if (g_gui_last_color != c) { 97 | vm_graphic_color_argb_t color; 98 | color.a = (uint8_t)(c >> 24); 99 | color.r = (uint8_t)(c >> 16); 100 | color.g = (uint8_t)(c >> 8); 101 | color.b = (uint8_t) c; 102 | vm_graphic_set_color(color); 103 | g_gui_last_color = c; 104 | } 105 | vm_graphic_draw_line(&g_frame, x1, y1, x2, y2); 106 | 107 | g_gui_changed = 1; 108 | return UG_RESULT_OK; 109 | } 110 | 111 | static UG_RESULT gui_fill_rectangle(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, 112 | UG_COLOR c) 113 | { 114 | if (g_gui_last_color != c) { 115 | vm_graphic_color_argb_t color; 116 | color.a = (uint8_t)(c >> 24); 117 | color.r = (uint8_t)(c >> 16); 118 | color.g = (uint8_t)(c >> 8); 119 | color.b = (uint8_t) c; 120 | vm_graphic_set_color(color); 121 | g_gui_last_color = c; 122 | } 123 | vm_graphic_draw_solid_rectangle(&g_frame, x1, y1, x2 - x1 + 1, y2 - y1 + 1); 124 | 125 | g_gui_changed = 1; 126 | return UG_RESULT_OK; 127 | } 128 | 129 | static void gui_timer_callback(VM_TIMER_ID_PRECISE tid, void* user_data) 130 | { 131 | static int count = 0; 132 | vm_graphic_point_t positions[1] = { 0, 0 }; 133 | 134 | if (screen_suspend()) { 135 | return; 136 | } 137 | 138 | count++; 139 | if (count >= 10) { 140 | count = 0; 141 | time_update_callback(); 142 | } 143 | 144 | UG_Update(); 145 | 146 | if (g_gui_changed) { 147 | vm_graphic_rotate_frame(&g_rotated_frame, &g_frame, VM_GRAPHIC_ROTATE_180); 148 | vm_graphic_blt_frame(g_frame_blt_group, positions, 1); 149 | g_gui_changed = 0; 150 | } 151 | } 152 | 153 | void handle_touchevt(VM_TOUCH_EVENT event, VMINT x, VMINT y) 154 | { 155 | vm_log_info("touch event=%d,touch x=%d,touch y=%d", event, x, y); 156 | /* output log to monitor or catcher */ 157 | 158 | screen_resume(); 159 | 160 | y = 239 - y - 8; 161 | x = 239 - x; 162 | 163 | if (event == VM_TOUCH_EVENT_TAP) { 164 | UG_TouchUpdate(x, y, TOUCH_STATE_PRESSED); 165 | } else if (event == VM_TOUCH_EVENT_RELEASE) { 166 | UG_TouchUpdate(x, y, TOUCH_STATE_RELEASED); 167 | } 168 | 169 | UG_Update(); 170 | 171 | if (g_gui_changed) { 172 | vm_graphic_point_t positions[1] = { 0, 0 }; 173 | 174 | vm_graphic_rotate_frame(&g_rotated_frame, &g_frame, VM_GRAPHIC_ROTATE_180); 175 | vm_graphic_blt_frame(g_frame_blt_group, positions, 1); 176 | g_gui_changed = 0; 177 | } 178 | } 179 | 180 | void gui_setup(void) 181 | { 182 | // Initialize lcd and touch panel 183 | g_frame.width = 240; 184 | g_frame.height = 240; 185 | g_frame.color_format = VM_GRAPHIC_COLOR_FORMAT_16_BIT; 186 | g_frame.buffer = (VMUINT8*) vm_malloc_dma( 187 | g_frame.width * g_frame.height * 2); 188 | g_frame.buffer_length = (g_frame.width * g_frame.height * 2); 189 | 190 | g_rotated_frame.width = 240; 191 | g_rotated_frame.height = 240; 192 | g_rotated_frame.color_format = VM_GRAPHIC_COLOR_FORMAT_16_BIT; 193 | g_rotated_frame.buffer = (VMUINT8*) vm_malloc_dma( 194 | g_rotated_frame.width * g_rotated_frame.height * 2); 195 | g_rotated_frame.buffer_length = (g_rotated_frame.width * g_rotated_frame.height * 2); 196 | 197 | g_frame_blt_group[0] = &g_rotated_frame; 198 | 199 | UG_Init(&g_gui, gui_draw_point, 240, 240); 200 | UG_SelectGUI(&g_gui); 201 | UG_DriverRegister(DRIVER_DRAW_LINE, (void *) gui_draw_line); 202 | UG_DriverRegister(DRIVER_FILL_FRAME, (void *) gui_fill_rectangle); 203 | UG_DriverEnable(DRIVER_DRAW_LINE); 204 | UG_DriverEnable(DRIVER_FILL_FRAME); 205 | 206 | // vm_touch_register_event_callback(handle_touchevt); 207 | 208 | /* create GUI update timer */ 209 | //g_timer_id = vm_timer_create_precise(100, gui_timer_callback, NULL); 210 | g_timer_id = vm_timer_create_non_precise(100, gui_timer_callback, NULL); 211 | } 212 | 213 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lvoicecall.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "vmlog.h" 4 | #include "vmgsm_tel.h" 5 | #include "vmchset.h" 6 | #include "vmgsm_sim.h" 7 | #include "string.h" 8 | #include "lvoicecall.h" 9 | 10 | 11 | vm_gsm_tel_call_listener_callback g_call_status_callback = NULL; 12 | 13 | static void (*g_call_state_changed_callback)(VMINT8) = NULL; 14 | 15 | 16 | vm_gsm_tel_id_info_t g_uid_info; 17 | VMINT8 g_call_status = IDLE_CALL; 18 | VMINT8 g_number[42]; 19 | 20 | 21 | void call_listener_func(vm_gsm_tel_call_listener_data_t* data) 22 | { 23 | vm_log_info("call_listener_func"); 24 | 25 | if(data->call_type == VM_GSM_TEL_INDICATION_INCOMING_CALL) 26 | { 27 | vm_gsm_tel_call_info_t* ind = (vm_gsm_tel_call_info_t*)data->data; 28 | g_uid_info.call_id = ind->uid_info.call_id; 29 | g_uid_info.group_id = ind->uid_info.group_id; 30 | g_uid_info.sim = ind->uid_info.sim; 31 | strcpy(g_number, (char*)ind->num_uri); 32 | g_call_status = RECEIVINGCALL; 33 | 34 | vm_log_info("incoming call"); 35 | } 36 | 37 | else if(data->call_type == VM_GSM_TEL_INDICATION_OUTGOING_CALL) 38 | { 39 | vm_gsm_tel_call_info_t* ind = (vm_gsm_tel_call_info_t*)data->data; 40 | g_uid_info.call_id = ind->uid_info.call_id; 41 | g_uid_info.group_id = ind->uid_info.group_id; 42 | g_uid_info.sim = ind->uid_info.sim; 43 | strcpy(g_number, (char*)ind->num_uri); 44 | g_call_status = CALLING; 45 | 46 | vm_log_info("calling"); 47 | } 48 | 49 | else if(data->call_type == VM_GSM_TEL_INDICATION_CONNECTED) 50 | { 51 | vm_gsm_tel_connect_indication_t* ind = (vm_gsm_tel_connect_indication_t*)data->data; 52 | g_uid_info.call_id = ind->uid_info.call_id; 53 | g_uid_info.group_id = ind->uid_info.group_id; 54 | g_uid_info.sim = ind->uid_info.sim; 55 | g_call_status = TALKING; 56 | 57 | vm_log_info("connected"); 58 | } 59 | 60 | else if(data->call_type == VM_GSM_TEL_INDICATION_CALL_ENDED) 61 | { 62 | g_call_status = IDLE_CALL; 63 | vm_log_info("endded"); 64 | } 65 | 66 | else 67 | { 68 | vm_log_info("bad operation type"); 69 | } 70 | 71 | vm_log_info("g_call_status is %d",g_call_status); 72 | 73 | if (g_call_state_changed_callback) { 74 | g_call_state_changed_callback(g_call_status); 75 | } 76 | } 77 | 78 | void callregisterCallback(void (*call_state_changed_callback)(VMINT8)) 79 | { 80 | g_call_state_changed_callback = call_state_changed_callback; 81 | 82 | vm_gsm_tel_call_reg_listener(call_listener_func); 83 | } 84 | 85 | static void call_voiceCall_callback(vm_gsm_tel_call_actions_callback_data_t* data) 86 | { 87 | vm_log_info("call_voiceCall_callback"); 88 | 89 | if(data->type_action == VM_GSM_TEL_CALL_ACTION_DIAL) 90 | { 91 | 92 | if(data->data_act_rsp.result_info.result == VM_GSM_TEL_OK) 93 | { 94 | g_call_status = CALLING; 95 | } 96 | else 97 | { 98 | g_call_status = IDLE_CALL; 99 | } 100 | } 101 | 102 | else if(data->type_action == VM_GSM_TEL_CALL_ACTION_ACCEPT) 103 | { 104 | if(data->data_act_rsp.result_info.result == VM_GSM_TEL_OK) 105 | { 106 | g_call_status = TALKING; 107 | } 108 | else 109 | { 110 | g_call_status = IDLE_CALL; 111 | } 112 | } 113 | 114 | else if(data->type_action == VM_GSM_TEL_CALL_ACTION_HOLD) 115 | { 116 | 117 | } 118 | 119 | else if(data->type_action == VM_GSM_TEL_CALL_ACTION_END_SINGLE) 120 | { 121 | g_call_status = IDLE_CALL; 122 | } 123 | else 124 | { 125 | 126 | } 127 | } 128 | 129 | VMUINT8 callvoiceCall(void* user_data) 130 | { 131 | VMINT ret; 132 | char* to = (char*)user_data; 133 | call_info_struct callInfo; 134 | strcpy(callInfo.num, to); 135 | 136 | vm_gsm_tel_dial_action_request_t req; 137 | vm_gsm_tel_call_actions_data_t data; 138 | 139 | //vm_log_info("callvoiceCall"); 140 | 141 | req.sim = VM_GSM_TEL_CALL_SIM_1; 142 | req.is_ip_dial = 0; 143 | req.module_id = 0; 144 | 145 | vm_chset_ascii_to_ucs2((VMWSTR)req.num_uri, VM_GSM_TEL_MAX_NUMBER_LENGTH, (VMSTR)&callInfo.num); 146 | 147 | req.phonebook_data = NULL; 148 | 149 | data.action = VM_GSM_TEL_CALL_ACTION_DIAL; 150 | data.data_action = (void*)&req; 151 | data.user_data = NULL; 152 | data.callback = call_voiceCall_callback; 153 | 154 | ret = vm_gsm_tel_call_actions(&data); 155 | 156 | vm_gsm_tel_set_output_device(VM_GSM_TEL_DEVICE_LOUDSPK); 157 | vm_gsm_tel_set_volume(VM_AUDIO_VOLUME_6); 158 | 159 | if(ret < 0) 160 | { 161 | vm_log_info("callvoiceCall FALSE"); 162 | callInfo.result = 0; 163 | return FALSE; 164 | } 165 | else 166 | { 167 | vm_log_info("callvoiceCall TRUE"); 168 | callInfo.result = 1; 169 | return TRUE; 170 | } 171 | } 172 | 173 | VMUINT8 callanswerCall(void* user_data) 174 | { 175 | VMINT ret; 176 | vm_gsm_tel_single_call_action_request_t req; 177 | vm_gsm_tel_call_actions_data_t data; 178 | 179 | req.action_id.sim = g_uid_info.sim; 180 | req.action_id.call_id = g_uid_info.call_id; 181 | req.action_id.group_id = g_uid_info.group_id; 182 | 183 | data.action = VM_GSM_TEL_CALL_ACTION_ACCEPT; 184 | data.data_action = (void*)&req; 185 | data.user_data = NULL; 186 | data.callback = call_voiceCall_callback; 187 | 188 | ret = vm_gsm_tel_call_actions(&data); 189 | 190 | vm_gsm_tel_set_output_device(VM_GSM_TEL_DEVICE_LOUDSPK); 191 | vm_gsm_tel_set_volume(VM_AUDIO_VOLUME_6); 192 | 193 | if(ret < 0) 194 | { 195 | vm_log_info("callanswerCall FALSE"); 196 | return FALSE; 197 | } 198 | else 199 | { 200 | vm_log_info("callanswerCall true"); 201 | return TRUE; 202 | } 203 | } 204 | 205 | VMUINT8 callhangCall(void* user_data) 206 | { 207 | VMINT ret; 208 | vm_gsm_tel_single_call_action_request_t req; 209 | vm_gsm_tel_call_actions_data_t data; 210 | 211 | //vm_log_info("callhangCall"); 212 | 213 | if(IDLE_CALL == g_call_status)return; 214 | 215 | // req.action_id.sim = g_uid_info.sim; 216 | // req.action_id.call_id = g_uid_info.call_id; 217 | // req.action_id.group_id = g_uid_info.group_id; 218 | req.action_id.sim = 1; 219 | req.action_id.call_id = 1; 220 | req.action_id.group_id = 1; 221 | 222 | data.action = VM_GSM_TEL_CALL_ACTION_END_SINGLE; 223 | data.data_action = (void*)&req; 224 | data.user_data = NULL; 225 | data.callback = call_voiceCall_callback; 226 | 227 | ret = vm_gsm_tel_call_actions(&data); 228 | 229 | if(ret < 0) 230 | { 231 | vm_log_info("callhangCall FALSE"); 232 | return FALSE; 233 | } 234 | else 235 | { 236 | vm_log_info("callhangCall TRUE"); 237 | return TRUE; 238 | } 239 | } 240 | 241 | 242 | void callretrieveCallingNumber(void* user_data) 243 | { 244 | VMINT8* callInfo = (VMINT8*)user_data; 245 | 246 | if(g_call_status == RECEIVINGCALL) 247 | { 248 | strcpy(callInfo, g_number); 249 | } 250 | } 251 | 252 | void callgetVoiceCallStatus(void* user_data) 253 | { 254 | char* status = (char*)user_data; 255 | 256 | *status = g_call_status; 257 | } 258 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmtype.h" 3 | #include "vmlog.h" 4 | #include "vmcmd.h" 5 | #include "vmsystem.h" 6 | #include "vmgraphic.h" 7 | #include "vmgraphic_font.h" 8 | #include "vmboard.h" 9 | #include "ugui.h" 10 | #include "lvoicecall.h" 11 | #include "vmgsm_tel.h" 12 | #include "vmgsm_sim.h" 13 | #include "vmtimer.h" 14 | #include "vmdatetime.h" 15 | #include "sensor.h" 16 | #include "vmtouch.h" 17 | #include "ldlcgpio.h" 18 | #include "ldlceint.h" 19 | #include "lrgbws2812.h" 20 | #include "lledmatrix.h" 21 | #include "vmdcl_kbd.h" 22 | #include "vmkeypad.h" 23 | #include "sensor.h" 24 | #include "ifttt_book.h" 25 | 26 | 27 | #ifdef CUSTOM_TOUCHPAD 28 | #include "tp_focaitech_ft6x06.h" 29 | #else 30 | #include "tp_goodix_gt9xx.h" 31 | #endif 32 | 33 | #define COMMAND_PORT 1000 34 | 35 | #define RECORD_FLAG 1 36 | 37 | #define RLED_GPIO 17 38 | #define GLED_GPIO 15 39 | #define BLED_GPIO 12 40 | 41 | VM_TIMER_ID_PRECISE sys_timer_id = 0; 42 | static VMUINT8* g_font_pool; 43 | VMUINT8 sys_record_time = 0; 44 | unsigned char sys_blink = 0; 45 | 46 | 47 | extern void gui_setup(void); 48 | extern void windows_create(void); 49 | extern void handle_touchevt(VM_TOUCH_EVENT event, VMINT x, VMINT y); 50 | extern void screen_resume(void); 51 | extern void lcd_backlight_level(VMUINT32 ulValue); 52 | 53 | 54 | void sys_gpio_init(void){ 55 | pinMode(RLED_GPIO,OUTPUT); 56 | pinMode(GLED_GPIO,OUTPUT); 57 | pinMode(BLED_GPIO,OUTPUT); 58 | 59 | pinMode(10, OUTPUT); 60 | pinMode(11, OUTPUT); 61 | 62 | digitalWrite(RLED_GPIO, 0); 63 | digitalWrite(GLED_GPIO, 1); 64 | digitalWrite(BLED_GPIO, 0); 65 | 66 | digitalWrite(10, 0); 67 | digitalWrite(11, 0); 68 | } 69 | 70 | void key_init(void){ 71 | VM_DCL_HANDLE kbd_handle; 72 | vm_dcl_kbd_control_pin_t kbdmap; 73 | 74 | kbd_handle = vm_dcl_open(VM_DCL_KBD,0); 75 | kbdmap.col_map = 0x09; 76 | kbdmap.row_map =0x05; 77 | vm_dcl_control(kbd_handle,VM_DCL_KBD_COMMAND_CONFIG_PIN, (void *)(&kbdmap)); 78 | 79 | vm_dcl_close(kbd_handle); 80 | } 81 | 82 | static void font_init(void){ 83 | VM_RESULT result; 84 | VMUINT32 pool_size; 85 | 86 | result = vm_graphic_get_font_pool_size(0, 0, 0, &pool_size); 87 | if(VM_IS_SUCCEEDED(result)) 88 | { 89 | g_font_pool = (VMUINT8* )vm_malloc(pool_size); 90 | if(NULL != g_font_pool) 91 | { 92 | vm_graphic_init_font_pool(g_font_pool, pool_size); 93 | } else { 94 | vm_log_info("allocate font pool memory failed, pool size: %d", pool_size); 95 | } 96 | } 97 | else 98 | { 99 | vm_log_info("get font pool size failed, result:%d", result); 100 | } 101 | } 102 | 103 | 104 | #ifdef CUSTOM_TOUCHPAD 105 | void handle_touch() 106 | { 107 | static uint8_t is_pressed = 0; 108 | 109 | vm_drv_tp_multiple_event_t tpdata = {0}; 110 | ctp_focaitech_ft6x06_get_data(&tpdata); 111 | 112 | if (!(tpdata.points[0].x == 0 && tpdata.points[0].y == 0)) { 113 | handle_touchevt(VM_TOUCH_EVENT_TAP, tpdata.points[0].x, tpdata.points[0].y); 114 | } else { 115 | handle_touchevt(VM_TOUCH_EVENT_RELEASE, tpdata.points[0].x, tpdata.points[0].y); 116 | } 117 | 118 | is_pressed = 1 - is_pressed; 119 | } 120 | #endif 121 | 122 | void command_callback(vm_cmd_command_t *param, void *user_data) 123 | { 124 | vm_log_info("cmd = %s", (char*)param->command_buffer); 125 | 126 | if(strcmp("LOFF",(char*)param->command_buffer) == 0) 127 | { 128 | lcd_backlight_level(2); 129 | } 130 | else if(strcmp("LON",(char*)param->command_buffer) == 0) 131 | { 132 | lcd_backlight_level(50); 133 | } 134 | else if(strcmp("BUTTON",(char*)param->command_buffer) == 0) 135 | { 136 | sensor_t *button; 137 | screen_resume(); 138 | button = sensor_find(BUTTON_ID); 139 | button->u32 = 1; 140 | ifttt_check(); 141 | button->u32 = 0; 142 | } 143 | } 144 | 145 | void sys_timer_callback(VM_TIMER_ID_PRECISE sys_timer_id, void* user_data) 146 | { 147 | sensor_update(); 148 | 149 | vm_gsm_tel_set_volume(VM_AUDIO_VOLUME_6); 150 | 151 | if(RECORD_FLAG == 1) 152 | { 153 | if((sys_record_time ++) >= 60) 154 | { 155 | vm_date_time_t data_time; 156 | VMUINT8 str[25]; 157 | sys_record_time = 0; 158 | vm_time_get_date_time(&data_time); 159 | sprintf(str, "%d-%d-%d, %d:%d:%d \r\n", data_time.year, data_time.month, data_time.day, data_time.hour, data_time.minute, data_time.second); 160 | file_write("system_record.txt", str, 0); 161 | } 162 | } 163 | 164 | if(sys_blink)digitalWrite(GLED_GPIO, 1); 165 | else digitalWrite(GLED_GPIO, 0); 166 | sys_blink = !sys_blink; 167 | } 168 | 169 | VMINT handle_keypad_event(VM_KEYPAD_EVENT event, VMINT code){ 170 | /* output log to monitor or catcher */ 171 | vm_log_info("key event=%d,key code=%d",event,code); /* event value refer to VM_KEYPAD_EVENT */ 172 | 173 | if (code == 30) { 174 | if (event == 3) { // long pressed 175 | // turn off peripheral 176 | led_matrix_disp_pic(7, 0); 177 | } else if (event == 2) { // down 178 | sensor_t *button; 179 | 180 | screen_resume(); 181 | 182 | button = sensor_find(BUTTON_ID); 183 | button->u32 = 1; 184 | ifttt_check(); 185 | button->u32 = 0; 186 | } else if (event == 1) { // up 187 | 188 | } 189 | } 190 | return 0; 191 | } 192 | 193 | void handle_sysevt(VMINT message, VMINT param) 194 | { 195 | switch (message) { 196 | case VM_EVENT_CREATE: 197 | 198 | vm_log_info("Open AT Port & Reg Callback"); 199 | vm_cmd_open_port(COMMAND_PORT, command_callback, NULL); 200 | 201 | lcd_backlight_level(50); 202 | gui_setup(); 203 | 204 | #ifdef CUSTOM_TOUCHPAD 205 | attachInterrupt(25, handle_touch, CHANGE); 206 | 207 | #endif 208 | sensor_scan(); 209 | //sys_timer_id = vm_timer_create_precise(1000, sys_timer_callback, NULL); 210 | sys_timer_id = vm_timer_create_non_precise(1000, sys_timer_callback, NULL); 211 | break; 212 | case VM_EVENT_PAINT: 213 | windows_create(); 214 | digitalWrite(RLED_GPIO, 1); 215 | digitalWrite(BLED_GPIO, 1); 216 | break; 217 | case VM_EVENT_QUIT: 218 | break; 219 | } 220 | } 221 | 222 | /* Entry point */ 223 | void vm_main(void) 224 | { 225 | sys_gpio_init(); 226 | font_init(); 227 | lcd_st7789s_init(); 228 | #ifdef CUSTOM_TOUCHPAD 229 | tp_ft6x06_init(); 230 | #else 231 | tp_gt9xx_init(); 232 | vm_touch_register_event_callback(handle_touchevt); 233 | #endif 234 | key_init(); 235 | vm_keypad_register_event_callback(handle_keypad_event); 236 | //rgb_ws2812_power_on(); 237 | 238 | ifttt_book_open(); 239 | if(RECORD_FLAG == 1)file_open("system_record.txt"); 240 | 241 | /* register system events handler */ 242 | vm_pmng_register_system_event_callback(handle_sysevt); 243 | } 244 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/RePhone_Create_Source_Code.proj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 29 | 33 | 36 | 39 | 42 | 51 | 70 | 73 | 78 | 81 | 98 | 101 | 104 | 107 | 112 | 115 | 118 | 122 | 123 | 133 | 137 | 140 | 143 | 146 | 155 | 170 | 173 | 178 | 181 | 194 | 197 | 200 | 203 | 208 | 211 | 214 | 217 | 218 | 219 | 220 | 221 | 222 | 226 | 229 | 230 | 233 | 234 | 235 | 239 | 242 | 243 | 244 | 248 | 251 | 252 | 253 | 256 | 257 | 258 | 259 | 260 | 261 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/cjson.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009 Dave Gamble 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #ifndef _CJSON__h 24 | #define _CJSON__h 25 | 26 | #ifdef __cplusplus 27 | extern "C" 28 | { 29 | #endif 30 | 31 | /* cJSON Types: */ 32 | #define cJSON_False 0 33 | #define cJSON_True 1 34 | #define cJSON_NULL 2 35 | #define cJSON_Number 3 36 | #define cJSON_String 4 37 | #define cJSON_Array 5 38 | #define cJSON_Object 6 39 | 40 | #define cJSON_IsReference 256 41 | 42 | /* The cJSON structure: */ 43 | typedef struct cJSON { 44 | struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ 45 | struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ 46 | 47 | int type; /* The type of the item, as above. */ 48 | 49 | char *valuestring; /* The item's string, if type==cJSON_String */ 50 | int valueint; /* The item's number, if type==cJSON_Number */ 51 | double valuedouble; /* The item's number, if type==cJSON_Number */ 52 | 53 | char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ 54 | } cJSON; 55 | 56 | typedef struct cJSON_Hooks { 57 | void *(*malloc_fn)(size_t sz); 58 | void (*free_fn)(void *ptr); 59 | } cJSON_Hooks; 60 | 61 | /* Supply malloc, realloc and free functions to cJSON */ 62 | extern void cJSON_InitHooks(cJSON_Hooks* hooks); 63 | 64 | 65 | /* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */ 66 | extern cJSON *cJSON_Parse(const char *value); 67 | /* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */ 68 | extern char *cJSON_Print(cJSON *item, int depth); 69 | /* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */ 70 | extern char *cJSON_PrintUnformatted(cJSON *item, int depth); 71 | /* Delete a cJSON entity and all subentities. */ 72 | extern void cJSON_Delete(cJSON *c); 73 | 74 | /* Returns the number of items in an array (or object). */ 75 | extern int cJSON_GetArraySize(cJSON *array); 76 | /* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */ 77 | extern cJSON *cJSON_GetArrayItem(cJSON *array,int item); 78 | /* Get item "string" from object. Case insensitive. */ 79 | extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string); 80 | 81 | /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ 82 | extern const char *cJSON_GetErrorPtr(void); 83 | 84 | /* These calls create a cJSON item of the appropriate type. */ 85 | extern cJSON *cJSON_CreateNull(void); 86 | extern cJSON *cJSON_CreateTrue(void); 87 | extern cJSON *cJSON_CreateFalse(void); 88 | extern cJSON *cJSON_CreateBool(int b); 89 | extern cJSON *cJSON_CreateNumber(double num); 90 | extern cJSON *cJSON_CreateString(const char *string); 91 | extern cJSON *cJSON_CreateArray(void); 92 | extern cJSON *cJSON_CreateObject(void); 93 | 94 | /* These utilities create an Array of count items. */ 95 | extern cJSON *cJSON_CreateIntArray(int *numbers,int count); 96 | extern cJSON *cJSON_CreateFloatArray(float *numbers,int count); 97 | extern cJSON *cJSON_CreateDoubleArray(double *numbers,int count); 98 | extern cJSON *cJSON_CreateStringArray(const char **strings,int count); 99 | 100 | /* Append item to the specified array/object. */ 101 | extern void cJSON_AddItemToArray(cJSON *array, cJSON *item); 102 | extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item); 103 | /* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ 104 | extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); 105 | extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item); 106 | 107 | /* Remove/Detatch items from Arrays/Objects. */ 108 | extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which); 109 | extern void cJSON_DeleteItemFromArray(cJSON *array,int which); 110 | extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string); 111 | extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string); 112 | 113 | /* Update array items. */ 114 | extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem); 115 | extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); 116 | 117 | /* Duplicate a cJSON item */ 118 | extern cJSON *cJSON_Duplicate(cJSON *item,int recurse); 119 | /* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will 120 | need to be released. With recurse!=0, it will duplicate any children connected to the item. 121 | The item->next and ->prev pointers are always zero on return from Duplicate. */ 122 | 123 | /* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ 124 | extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated); 125 | 126 | /* Macros for creating things quickly. */ 127 | #define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) 128 | #define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) 129 | #define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) 130 | #define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b)) 131 | #define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n)) 132 | #define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s)) 133 | 134 | /* When assigning an integer value, it needs to be propagated to valuedouble too. */ 135 | #define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val)) 136 | 137 | #ifdef __cplusplus 138 | } 139 | #endif 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/led_matrix_window.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "ugui.h" 4 | #include "lledmatrix.h" 5 | 6 | UG_WINDOW *g_led_matrix_window_prev; 7 | UG_WINDOW g_led_matrix_window; 8 | UG_WINDOW g_led_matrix_time_window; 9 | const char *g_led_matrix_button_text[15] = { "0", "1", "2", "3", "4", "5", "6", 10 | "7", "8", "9", "a", "b"}; 11 | static char g_led_matrix_display_char = ' '; 12 | static uint32_t *g_led_matrix_parameters = 0; 13 | char g_led_matrix_time_str[8] = {0,}; 14 | 15 | extern void input_window_show(char *buf, int len, int id); 16 | 17 | void led_matrix_time_window_create(); 18 | 19 | static void led_matrix_window_callback(UG_MESSAGE *msg) 20 | { 21 | char ch; 22 | if (msg->type == MSG_TYPE_OBJECT) { 23 | if (msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 24 | switch (msg->sub_id) { 25 | case 15: // text 26 | break; 27 | case 14: 28 | break; 29 | case 13: 30 | break; 31 | case 12: // return 32 | UG_WindowShow(g_led_matrix_window_prev); 33 | break; 34 | default: { 35 | ch = g_led_matrix_button_text[msg->sub_id][0]; 36 | g_led_matrix_display_char = ch; 37 | UG_WindowShow(&g_led_matrix_time_window); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | void led_matrix_window_create(void) 45 | { 46 | static UG_BUTTON buttons[16]; 47 | static UG_OBJECT objects[16]; 48 | char *icons[] = {"1", "3", "4"}; 49 | int i = 0; 50 | int j = 0; 51 | 52 | UG_WindowCreate(&g_led_matrix_window, objects, 16, 53 | led_matrix_window_callback); 54 | UG_WindowSetStyle(&g_led_matrix_window, WND_STYLE_2D); 55 | 56 | for (i = 0; i < 4; i++) { 57 | for (j = 0; j < 3; j++) { 58 | int index = i * 3 + j; 59 | UG_ButtonCreate(&g_led_matrix_window, buttons + index, index, 60 | 80 * j, 40 * (i + 1), 80 * (j + 1) - 1, 40 * (i + 2) - 1); 61 | UG_ButtonSetFont(&g_led_matrix_window, index, &FONT_SIZE20); 62 | UG_ButtonSetText(&g_led_matrix_window, index, 63 | g_led_matrix_button_text[index]); 64 | UG_ButtonSetStyle(&g_led_matrix_window, index, 65 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS 66 | | BTN_STYLE_NO_BORDERS); 67 | } 68 | } 69 | 70 | for (j = 0; j < 3; j++) { 71 | int index = 4 * 3 + j; 72 | UG_ButtonCreate(&g_led_matrix_window, buttons + index, index, 80 * j, 73 | 40 * (i + 1), 80 * (j + 1) - 1, 40 * (i + 2) - 1); 74 | UG_ButtonSetFont(&g_led_matrix_window, index, &FONT_ICON24); 75 | UG_ButtonSetText(&g_led_matrix_window, index, 76 | icons[j]); 77 | UG_ButtonSetStyle(&g_led_matrix_window, index, 78 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 79 | } 80 | 81 | UG_ButtonCreate(&g_led_matrix_window, buttons + 15, 15, 0, 0, 239, 39); 82 | UG_ButtonSetFont(&g_led_matrix_window, 15, &FONT_SIZE20); 83 | UG_ButtonSetText(&g_led_matrix_window, 15, "led matrix"); 84 | UG_ButtonSetStyle(&g_led_matrix_window, 15, 85 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 86 | UG_ButtonSetBackColor(&g_led_matrix_window, 15, 0); 87 | 88 | led_matrix_time_window_create(); 89 | } 90 | 91 | void led_matrix_window_show(uint32_t *pdata) 92 | { 93 | g_led_matrix_parameters = pdata; 94 | g_led_matrix_window_prev = UG_GetActiveWindow(); 95 | 96 | UG_WindowShow(&g_led_matrix_window); 97 | } 98 | 99 | void led_matrix_time_window_callback(UG_MESSAGE *msg) 100 | { 101 | if (msg->type == MSG_TYPE_OBJECT) { 102 | if (msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 103 | int duration; 104 | switch (msg->sub_id) { 105 | case 1: 106 | input_window_show(g_led_matrix_time_str, sizeof(g_led_matrix_time_str), 1); 107 | break; 108 | case 2: 109 | UG_WindowShow(&g_led_matrix_window); 110 | break; 111 | case 3: 112 | duration = atoi(g_led_matrix_time_str); 113 | 114 | if (g_led_matrix_parameters) { 115 | g_led_matrix_parameters[0] = (unsigned)g_led_matrix_display_char; 116 | g_led_matrix_parameters[1] = duration; 117 | } else { 118 | led_matrix_disp_char(g_led_matrix_display_char, duration); 119 | } 120 | 121 | UG_WindowShow(g_led_matrix_window_prev); 122 | g_led_matrix_parameters = 0; 123 | break; 124 | } 125 | 126 | } 127 | } 128 | } 129 | 130 | void led_matrix_time_window_create(void) 131 | { 132 | static UG_BUTTON buttons[6]; 133 | static UG_OBJECT objects[6]; 134 | char *button_texts[] = { "Run Time (s)", ""}; 135 | int offset; 136 | 137 | UG_WindowCreate(&g_led_matrix_time_window, objects, 138 | sizeof(objects) / sizeof(*objects), led_matrix_time_window_callback); 139 | UG_WindowSetStyle(&g_led_matrix_time_window, WND_STYLE_2D); 140 | 141 | 142 | for (offset = 0; offset < 2; offset++) { 143 | UG_ButtonCreate(&g_led_matrix_time_window, buttons + offset, offset, 0, 144 | 40 * offset + 40, 239, 40 * offset + 80 - 1); 145 | UG_ButtonSetFont(&g_led_matrix_time_window, offset, &FONT_SIZE20); 146 | 147 | if (offset % 2) { 148 | UG_ButtonSetStyle(&g_led_matrix_time_window, offset, 149 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 150 | } else { 151 | UG_ButtonSetStyle(&g_led_matrix_time_window, offset, 152 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 153 | UG_ButtonSetBackColor(&g_led_matrix_time_window, offset, 0); 154 | } 155 | 156 | UG_ButtonSetAlignment(&g_led_matrix_time_window, offset, ALIGN_CENTER_LEFT); 157 | UG_ButtonSetHSpace(&g_led_matrix_time_window, offset, 8); 158 | 159 | UG_ButtonSetText(&g_led_matrix_time_window, offset, 160 | button_texts[offset]); 161 | } 162 | 163 | UG_ButtonCreate(&g_led_matrix_time_window, buttons + offset, offset, 0, 164 | 200, 119, 239); 165 | UG_ButtonSetFont(&g_led_matrix_time_window, offset, &FONT_ICON24); 166 | UG_ButtonSetText(&g_led_matrix_time_window, offset, "1"); 167 | UG_ButtonSetStyle(&g_led_matrix_time_window, offset, 168 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 169 | 170 | offset++; 171 | UG_ButtonCreate(&g_led_matrix_time_window, buttons + offset, offset, 120, 172 | 200, 239, 239); 173 | UG_ButtonSetFont(&g_led_matrix_time_window, offset, &FONT_ICON24); 174 | UG_ButtonSetText(&g_led_matrix_time_window, offset, ":"); 175 | UG_ButtonSetStyle(&g_led_matrix_time_window, offset, 176 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 177 | 178 | offset++; 179 | UG_ButtonCreate(&g_led_matrix_time_window, buttons + offset, offset, 0, 0, 239, 39); 180 | UG_ButtonSetFont(&g_led_matrix_time_window, offset, &FONT_SIZE20); 181 | UG_ButtonSetText(&g_led_matrix_time_window, offset, "LED Matrix"); 182 | UG_ButtonSetStyle(&g_led_matrix_time_window, offset, 183 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 184 | UG_ButtonSetBackColor(&g_led_matrix_time_window, offset, 0x000000); 185 | } 186 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/ldlceint.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmsystem.h" 3 | #include "vmtype.h" 4 | #include "vmlog.h" 5 | #include "vmdcl.h" 6 | #include "vmdcl_gpio.h" 7 | #include "vmdcl_eint.h" 8 | #include "string.h" 9 | #include "ldlceint.h" 10 | 11 | 12 | static Exinterrupts_Struct gExinterruptsPio[EXTERNAL_NUM_INTERRUPTS] = 13 | { 14 | {VM_DCL_HANDLE_INVALID, 0, 0, 0, NULL},// gpio0 15 | {VM_DCL_HANDLE_INVALID, 1, 1, 0, NULL},// gpio1 16 | {VM_DCL_HANDLE_INVALID, 2, 2, 0, NULL},// gpio2 17 | {VM_DCL_HANDLE_INVALID, 52, 23, 0, NULL},// agpio52 18 | {VM_DCL_HANDLE_INVALID, 13, 11, 0, NULL},// gpio13 19 | {VM_DCL_HANDLE_INVALID, 18, 13, 0, NULL},// gpio18 20 | {VM_DCL_HANDLE_INVALID, 25, 15, 0, NULL},// gpio25 21 | {VM_DCL_HANDLE_INVALID, 46, 20, 0, NULL},// gpio46 22 | {VM_DCL_HANDLE_INVALID, 10, 9, 0, NULL},// gpio10 23 | {VM_DCL_HANDLE_INVALID, 11, 10, 0, NULL},// gpio11 24 | }; 25 | 26 | VMUINT8 no_interrupt = 1; 27 | 28 | void interrupts(void) 29 | { 30 | no_interrupt = 0; 31 | } 32 | 33 | void noInterrupts(void ) 34 | { 35 | no_interrupt = 1; 36 | } 37 | 38 | VMUINT8 noStopInterrupts(void) 39 | { 40 | return no_interrupt; 41 | } 42 | 43 | static void eint_callback(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle) 44 | { 45 | int i; 46 | 47 | for(i=0; i 3 | #include "vmdcl.h" 4 | #include "vmdcl_pwm.h" 5 | #include "laudio.h" 6 | #include "lstorage.h" 7 | #include "vmmemory.h" 8 | #include "cjson.h" 9 | #include "ugui.h" 10 | #include "vmpwr.h" 11 | 12 | #define SCREEN_OFF_TIME 600 13 | 14 | UG_WINDOW g_settings_window; 15 | uint8_t g_settings_brightness = 3; 16 | uint8_t g_settings_sound = 3; 17 | char g_settings_brightness_str[4] = {'3', 0, 0 }; 18 | char g_settings_sound_str[2] = { '3', 0 }; 19 | uint8_t g_settings_is_changed = 0; 20 | 21 | uint8_t g_brightness_table[] = {2, 20, 40, 50, 60, 80, 100}; 22 | int g_screen_off_timeout = SCREEN_OFF_TIME; 23 | 24 | extern UG_WINDOW g_home_window; 25 | 26 | 27 | int screen_suspend(void) 28 | { 29 | if (g_screen_off_timeout > 0) { 30 | g_screen_off_timeout--; 31 | if (g_screen_off_timeout == 0) { 32 | lcd_backlight_level(0); 33 | vm_pwr_lcd_sleep_in(); 34 | } else { 35 | return 0; 36 | } 37 | } 38 | 39 | return 1; 40 | } 41 | 42 | void screen_resume(void) 43 | { 44 | if (g_screen_off_timeout == 0) { 45 | vm_pwr_lcd_sleep_out(); 46 | lcd_backlight_level(g_brightness_table[g_settings_brightness]); 47 | } 48 | 49 | g_screen_off_timeout = SCREEN_OFF_TIME; 50 | } 51 | 52 | void lcd_backlight_level(VMUINT32 ulValue) 53 | { 54 | VM_DCL_HANDLE pwm_handle; 55 | vm_dcl_pwm_set_clock_t pwm_clock; 56 | vm_dcl_pwm_set_counter_threshold_t pwm_config_adv; 57 | vm_dcl_config_pin_mode(3, VM_DCL_PIN_MODE_PWM); 58 | pwm_handle = vm_dcl_open(PIN2PWM(3), vm_dcl_get_owner_id()); 59 | vm_dcl_control(pwm_handle, VM_PWM_CMD_START, 0); 60 | pwm_config_adv.counter = 100; 61 | pwm_config_adv.threshold = ulValue; 62 | pwm_clock.source_clock = 0; 63 | pwm_clock.source_clock_division = 3; 64 | vm_dcl_control(pwm_handle, VM_PWM_CMD_SET_CLOCK, (void *) (&pwm_clock)); 65 | vm_dcl_control(pwm_handle, VM_PWM_CMD_SET_COUNTER_AND_THRESHOLD, 66 | (void *) (&pwm_config_adv)); 67 | vm_dcl_close(pwm_handle); 68 | } 69 | 70 | void settings_load() 71 | { 72 | unsigned long size = 0; 73 | file_size("settings.txt", &size); 74 | if (size < 24) { 75 | return; 76 | } 77 | 78 | char *ptr = vm_malloc(size); 79 | if (NULL == ptr) { 80 | return; 81 | } 82 | 83 | file_read("settings.txt", ptr, size, 0); 84 | 85 | cJSON *root = cJSON_Parse(ptr); 86 | if (NULL == root) { 87 | vm_free(ptr); 88 | return; 89 | } 90 | 91 | g_settings_brightness = cJSON_GetObjectItem(root, "brightness")->valueint; 92 | g_settings_sound = cJSON_GetObjectItem(root, "sound")->valueint; 93 | 94 | if (g_settings_brightness > 6) { 95 | g_settings_brightness = 6; 96 | } 97 | snprintf(g_settings_brightness_str, sizeof(g_settings_brightness_str), "%d", g_settings_brightness); 98 | 99 | if (g_settings_sound > 6) { 100 | g_settings_sound = 6; 101 | } 102 | g_settings_sound_str[0] = '0' + g_settings_sound; 103 | 104 | lcd_backlight_level(g_brightness_table[g_settings_brightness]); 105 | audioSetVolume(g_settings_sound); 106 | 107 | UG_ButtonSetText(&g_settings_window, 7, g_settings_brightness_str); 108 | UG_ButtonSetText(&g_settings_window, 4, g_settings_sound_str); 109 | 110 | vm_free(ptr); 111 | } 112 | 113 | void settings_save() 114 | { 115 | char buf[40]; 116 | snprintf(buf, sizeof(buf), "{\"brightness\":%d, \"sound\":%d}", g_settings_brightness, g_settings_sound); 117 | 118 | file_delete("settings.txt"); 119 | file_open("settings.txt"); 120 | file_write("settings.txt", buf, 0); 121 | } 122 | 123 | static void settings_window_callback(UG_MESSAGE *msg) 124 | { 125 | if (msg->type == MSG_TYPE_OBJECT) { 126 | if (msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 127 | switch (msg->sub_id) { 128 | case 0: // back 129 | if (g_settings_is_changed) { 130 | g_settings_is_changed = 0; 131 | settings_save(); 132 | } 133 | UG_WindowShow(&g_home_window); 134 | break; 135 | case 3: // - 136 | if (g_settings_sound > 0) { 137 | g_settings_is_changed = 1; 138 | g_settings_sound--; 139 | audioSetVolume(g_settings_sound); 140 | g_settings_sound_str[0] = '0' + g_settings_sound; 141 | UG_ButtonSetText(&g_settings_window, 4, 142 | g_settings_sound_str); 143 | } 144 | break; 145 | case 5: // + 146 | if (g_settings_sound < 6) { 147 | g_settings_is_changed = 1; 148 | g_settings_sound++; 149 | audioSetVolume(g_settings_sound); 150 | g_settings_sound_str[0] = '0' + g_settings_sound; 151 | UG_ButtonSetText(&g_settings_window, 4, 152 | g_settings_sound_str); 153 | } 154 | break; 155 | case 6: // - 156 | if (g_settings_brightness > 0) { 157 | g_settings_is_changed = 1; 158 | g_settings_brightness--; 159 | lcd_backlight_level(g_brightness_table[g_settings_brightness]); 160 | 161 | itoa(g_settings_brightness, g_settings_brightness_str, 162 | 10); 163 | UG_ButtonSetText(&g_settings_window, 7, 164 | g_settings_brightness_str); 165 | } 166 | break; 167 | case 8: // + 168 | if (g_settings_brightness < 6) { 169 | g_settings_is_changed = 1; 170 | g_settings_brightness++; 171 | lcd_backlight_level(g_brightness_table[g_settings_brightness]); 172 | 173 | itoa(g_settings_brightness, g_settings_brightness_str, 174 | 10); 175 | UG_ButtonSetText(&g_settings_window, 7, 176 | g_settings_brightness_str); 177 | } 178 | break; 179 | default: 180 | break; 181 | } 182 | } 183 | } 184 | } 185 | 186 | void settings_window_create(void) 187 | { 188 | char *button_texts[] = { "1", //icon font 189 | "", "", "-", "3", "+", "-", "3", "+"}; 190 | static UG_BUTTON buttons[16]; 191 | static UG_OBJECT objects[16]; 192 | int id = 0; 193 | int i = 0; 194 | int j = 0; 195 | 196 | UG_WindowCreate(&g_settings_window, objects, 16, settings_window_callback); 197 | UG_WindowSetStyle(&g_settings_window, WND_STYLE_2D); 198 | 199 | for (i = 0; i < 3; i++) { 200 | for (j = 0; j < 3; j++) { 201 | id = i * 3 + j; 202 | UG_ButtonCreate(&g_settings_window, buttons + id, id, 80 * j, 203 | 200 - i * 80, 80 * j + 79, 239 - i * 80); 204 | UG_ButtonSetFont(&g_settings_window, id, &FONT_SIZE20); 205 | UG_ButtonSetText(&g_settings_window, id, 206 | button_texts[id]); 207 | UG_ButtonSetStyle(&g_settings_window, id, 208 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS 209 | | BTN_STYLE_NO_BORDERS); 210 | } 211 | } 212 | 213 | UG_ButtonSetFont(&g_settings_window, 0, &FONT_ICON24); 214 | 215 | id++; 216 | UG_ButtonCreate(&g_settings_window, buttons + id, id, 0, 0, 239, 39); 217 | UG_ButtonSetFont(&g_settings_window, id, &FONT_SIZE20); 218 | UG_ButtonSetText(&g_settings_window, id, "Brightness"); 219 | UG_ButtonSetStyle(&g_settings_window, id, 220 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 221 | UG_ButtonSetBackColor(&g_settings_window, id, 0); 222 | 223 | id++; 224 | UG_ButtonCreate(&g_settings_window, buttons + id, id, 0, 80, 239, 119); 225 | UG_ButtonSetFont(&g_settings_window, id, &FONT_SIZE20); 226 | UG_ButtonSetText(&g_settings_window, id, "Sound"); 227 | UG_ButtonSetStyle(&g_settings_window, id, 228 | BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 229 | UG_ButtonSetBackColor(&g_settings_window, id, 0); 230 | 231 | settings_load(); 232 | } 233 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/call_ui.c: -------------------------------------------------------------------------------- 1 | 2 | #include "ugui.h" 3 | #include "vmlog.h" 4 | #include "lvoicecall.h" 5 | #include "laudio.h" 6 | #include "vmtimer.h" 7 | #include "address_book.h" 8 | #include "sensor.h" 9 | 10 | 11 | char g_incoming_phone_number[32]; 12 | int g_calling_time = 0; 13 | char g_calling_time_string[6] = { '0', '0', ':', '0', '0', 0 }; 14 | VM_TIMER_ID_PRECISE g_calling_timer_id; 15 | 16 | UG_WINDOW g_calling_window; 17 | UG_WINDOW g_incoming_call_window; 18 | 19 | extern UG_WINDOW g_home_window; 20 | 21 | extern void contact_list_window_create(); 22 | extern void contact_list_window_show(); 23 | extern void screen_resume(void); 24 | 25 | void update_calling_time_callback(VM_TIMER_ID_PRECISE tid, void* user_data) 26 | { 27 | g_calling_time++; 28 | g_calling_time_string[4] = '0' + (g_calling_time % 10); 29 | g_calling_time_string[3] = '0' + ((g_calling_time / 10) % 6); 30 | g_calling_time_string[1] = '0' + ((g_calling_time / 60) % 10); 31 | g_calling_time_string[0] = '0' + ((g_calling_time / 600) % 6); 32 | 33 | UG_TextboxSetText(&g_calling_window, TXB_ID_1, g_calling_time_string); 34 | } 35 | 36 | static void calling_window_callback(UG_MESSAGE *msg) 37 | { 38 | if (msg->type == MSG_TYPE_OBJECT) { 39 | if (msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 40 | callhangCall(0); 41 | 42 | vm_timer_delete_precise(g_calling_timer_id); 43 | UG_WindowShow(&g_home_window); 44 | } 45 | } 46 | } 47 | 48 | void calling_window_create(void) 49 | { 50 | static UG_BUTTON button; 51 | static UG_TEXTBOX textboxs[2]; 52 | static UG_OBJECT objects[3]; 53 | 54 | UG_WindowCreate(&g_calling_window, objects, 3, calling_window_callback); 55 | 56 | UG_TextboxCreate(&g_calling_window, textboxs, TXB_ID_0, 10, 10, 230, 80); 57 | UG_TextboxSetFont(&g_calling_window, TXB_ID_0, &FONT_SIZE20); 58 | 59 | UG_TextboxCreate(&g_calling_window, textboxs + 1, TXB_ID_1, 10, 90, 230, 60 | 170); 61 | UG_TextboxSetFont(&g_calling_window, TXB_ID_1, &FONT_SIZE20); 62 | 63 | UG_ButtonCreate(&g_calling_window, &button, BTN_ID_0, 0, 180, 239, 239); 64 | UG_ButtonSetFont(&g_calling_window, BTN_ID_0, &FONT_SIZE20); 65 | UG_ButtonSetText(&g_calling_window, BTN_ID_0, "END"); 66 | UG_ButtonSetStyle(&g_calling_window, BTN_ID_0, 67 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 68 | UG_ButtonSetBackColor(&g_calling_window, BTN_ID_0, 0xf44336); 69 | } 70 | 71 | void calling_window_show(char *phone_number) 72 | { 73 | char *status_string; 74 | char *action_string; 75 | 76 | if (callvoiceCall(phone_number) == TRUE) { 77 | status_string = "calling"; 78 | action_string = "END"; 79 | } else { 80 | status_string = "failed"; 81 | action_string = "BACK"; 82 | } 83 | 84 | UG_TextboxSetText(&g_calling_window, 0, phone_number); 85 | UG_TextboxSetText(&g_calling_window, 1, status_string); 86 | UG_WindowShow(&g_calling_window); 87 | } 88 | 89 | static void incoming_call_window_callback(UG_MESSAGE *msg) 90 | { 91 | if (msg->type == MSG_TYPE_OBJECT) { 92 | if (msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 93 | switch (msg->sub_id) { 94 | case 1: // accept 95 | callanswerCall(0); 96 | 97 | UG_TextboxSetText(&g_calling_window, TXB_ID_0, 98 | g_incoming_phone_number); 99 | vm_log_info("connected"); 100 | g_calling_time = 0; 101 | g_calling_time_string[0] = '0'; 102 | g_calling_time_string[1] = '0'; 103 | g_calling_time_string[3] = '0'; 104 | g_calling_time_string[4] = '0'; 105 | UG_TextboxSetText(&g_calling_window, TXB_ID_1, 106 | g_calling_time_string); 107 | g_calling_timer_id = vm_timer_create_precise(1000, 108 | update_calling_time_callback, NULL); 109 | 110 | UG_WindowShow(&g_calling_window); 111 | break; 112 | case 0: // reject 113 | callhangCall(0); 114 | audioStop(0); 115 | UG_WindowShow(&g_home_window); 116 | break; 117 | } 118 | 119 | } 120 | } 121 | } 122 | 123 | void incoming_call_window_create(void) 124 | { 125 | static UG_BUTTON buttons[2]; 126 | static UG_TEXTBOX textboxs[2]; 127 | static UG_OBJECT objects[4]; 128 | 129 | UG_WindowCreate(&g_incoming_call_window, objects, 4, 130 | incoming_call_window_callback); 131 | 132 | UG_TextboxCreate(&g_incoming_call_window, textboxs, TXB_ID_0, 10, 10, 230, 133 | 80); 134 | UG_TextboxSetFont(&g_incoming_call_window, TXB_ID_0, &FONT_SIZE20); 135 | 136 | UG_TextboxCreate(&g_incoming_call_window, textboxs + 1, TXB_ID_1, 10, 90, 137 | 230, 170); 138 | UG_TextboxSetFont(&g_incoming_call_window, TXB_ID_1, &FONT_SIZE20); 139 | UG_TextboxSetText(&g_incoming_call_window, TXB_ID_1, "incoming"); 140 | 141 | UG_ButtonCreate(&g_incoming_call_window, buttons, BTN_ID_0, 0, 180, 119, 142 | 239); 143 | UG_ButtonSetFont(&g_incoming_call_window, BTN_ID_0, &FONT_SIZE20); 144 | UG_ButtonSetText(&g_incoming_call_window, BTN_ID_0, "reject"); 145 | UG_ButtonSetStyle(&g_incoming_call_window, BTN_ID_0, 146 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 147 | UG_ButtonSetBackColor(&g_incoming_call_window, BTN_ID_0, 0xf44336); 148 | 149 | UG_ButtonCreate(&g_incoming_call_window, buttons + 1, BTN_ID_1, 120, 180, 150 | 239, 239); 151 | UG_ButtonSetFont(&g_incoming_call_window, BTN_ID_1, &FONT_SIZE20); 152 | UG_ButtonSetText(&g_incoming_call_window, BTN_ID_1, "accept"); 153 | UG_ButtonSetStyle(&g_incoming_call_window, BTN_ID_1, 154 | BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 155 | UG_ButtonSetBackColor(&g_incoming_call_window, BTN_ID_1, 0x4CAF50); 156 | } 157 | 158 | void incoming_call_window_show() 159 | { 160 | callretrieveCallingNumber(g_incoming_phone_number); 161 | 162 | UG_TextboxSetText(&g_incoming_call_window, TXB_ID_0, 163 | g_incoming_phone_number); 164 | UG_WindowShow(&g_incoming_call_window); 165 | } 166 | 167 | void call_state_changed_callback(VMINT8 state) 168 | { 169 | static uint8_t ringtone_is_playing = 0; 170 | vm_log_info("call event"); 171 | 172 | if (state == RECEIVINGCALL) { 173 | 174 | 175 | vm_log_info("incoming call"); 176 | 177 | // audioPlay(storageFlash, "ringtone.mp3"); 178 | ringtone_is_playing = 1; 179 | 180 | screen_resume(); 181 | incoming_call_window_show(); 182 | 183 | { 184 | sensor_t *call_sensor = sensor_find(CALL_ID); 185 | call_sensor->p = g_incoming_phone_number; 186 | ifttt_check();; 187 | } 188 | } else if (state == CALLING) { 189 | vm_log_info("calling"); 190 | } else if (state == TALKING) { 191 | if (ringtone_is_playing) { 192 | ringtone_is_playing = 0; 193 | // audioStop(NULL); 194 | } 195 | 196 | vm_log_info("connected"); 197 | g_calling_time = 0; 198 | g_calling_time_string[0] = '0'; 199 | g_calling_time_string[1] = '0'; 200 | g_calling_time_string[3] = '0'; 201 | g_calling_time_string[4] = '0'; 202 | UG_TextboxSetText(&g_calling_window, TXB_ID_1, g_calling_time_string); 203 | g_calling_timer_id = vm_timer_create_precise(1000, 204 | update_calling_time_callback, NULL); 205 | } else if (state == IDLE_CALL) { 206 | vm_log_info("endded"); 207 | 208 | if (ringtone_is_playing) { 209 | ringtone_is_playing = 0; 210 | // audioStop(NULL); 211 | } 212 | 213 | vm_timer_delete_precise(g_calling_timer_id); 214 | 215 | UG_WindowShow(&g_home_window); 216 | 217 | { 218 | sensor_t *call_sensor = sensor_find(CALL_ID); 219 | call_sensor->p = 0; 220 | ifttt_check(); 221 | } 222 | } 223 | } 224 | 225 | 226 | 227 | void call_window_create() 228 | { 229 | contact_list_window_create(); 230 | incoming_call_window_create(); 231 | calling_window_create(); 232 | 233 | callregisterCallback(call_state_changed_callback); 234 | } 235 | 236 | void call_window_show() 237 | { 238 | contact_list_window_show(); 239 | } 240 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/lgsmsms.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "vmlog.h" 4 | #include "vmdcl.h" 5 | #include "vmgsm_sim.h" 6 | #include "vmgsm_sms.h" 7 | #include "vmmemory.h" 8 | #include "stdio.h" 9 | #include "string.h" 10 | #include "vmdatetime.h" 11 | #include "lstorage.h" 12 | #include "lgsmsms.h" 13 | #include "lstorage.h" 14 | 15 | 16 | sms_send_struct g_sms_send_data; 17 | void (*g_sms_new_message_cb)(char *, char *) = NULL; 18 | void (*g_sms_send_message_cb)(int) = NULL; 19 | 20 | unsigned int msgIdMax = 0; // max SMS id 21 | char msgNumber[GSM_SMS_NUM_MAX][42] = {0}; // number data of current SMS 22 | char msgContent[GSM_SMS_NUM_MAX][151] = {0}; // content data of current SMS 23 | 24 | #define MAX_CONTENT_BUFFER 451 25 | char content[MAX_CONTENT_BUFFER]; 26 | 27 | 28 | void sms_inbox_open(); 29 | void sms_inbox_save(); 30 | void sms_inbox_show(); 31 | 32 | 33 | VMUINT8 gsm_sms_ready(void) 34 | { 35 | if(vm_gsm_sim_get_card_count() > 0 && vm_gsm_sms_is_sms_ready()) 36 | { 37 | return TRUE; 38 | } 39 | else 40 | { 41 | return FALSE; 42 | } 43 | } 44 | 45 | void sms_send_callback(vm_gsm_sms_callback_t* callback_data) 46 | { 47 | g_sms_send_data.result = callback_data->result; 48 | 49 | vm_log_debug("sms end result: %d", callback_data->result); 50 | 51 | if (g_sms_send_message_cb) { 52 | g_sms_send_message_cb(callback_data->result); 53 | } 54 | } 55 | 56 | VMUINT8 gsm_sms_begin(void* userdata) 57 | { 58 | char* to = (char*)userdata; 59 | strcpy(g_sms_send_data.number, to); 60 | 61 | return TRUE; 62 | } 63 | 64 | VMUINT8 gsm_sms_send(void* userdata) 65 | { 66 | char* to = (char*)userdata; 67 | strcpy(g_sms_send_data.content, to); 68 | 69 | VMWCHAR number[42]; 70 | VMWCHAR content[151]; 71 | 72 | VMUINT8 res; 73 | 74 | vm_chset_ascii_to_ucs2(content, 151*2, g_sms_send_data.content); 75 | 76 | vm_chset_ascii_to_ucs2(number, 42*2, g_sms_send_data.number); 77 | 78 | res = vm_gsm_sms_send(number, content, sms_send_callback, NULL); 79 | 80 | if(res == 0) 81 | { 82 | g_sms_send_data.result = TRUE; 83 | vm_log_debug("sms send success!"); 84 | return TRUE; 85 | } 86 | else 87 | { 88 | g_sms_send_data.result = FALSE; 89 | vm_log_debug("sms send fail!"); 90 | return FALSE; 91 | } 92 | } 93 | 94 | void sms_read_callback(vm_gsm_sms_callback_t* callback_data) 95 | { 96 | static char phone_number[42]; 97 | //static char content[301]; 98 | vm_gsm_sms_read_message_data_callback_t* read_msg; 99 | VMINT8 *g_sms_number_buf = 0; 100 | VMINT8 *g_sms_content_buf = 0; 101 | 102 | vm_log_info("got new message"); 103 | if(callback_data->action == VM_GSM_SMS_ACTION_READ) 104 | { 105 | if(callback_data->cause == VM_GSM_SMS_CAUSE_NO_ERROR) 106 | { 107 | if(callback_data->action_data) 108 | { 109 | read_msg = (vm_gsm_sms_read_message_data_callback_t*)callback_data->action_data; 110 | 111 | int size = vm_wstr_string_length((VMWCHAR*)read_msg->message_data->number); 112 | g_sms_number_buf = phone_number; 113 | vm_chset_ucs2_to_ascii((signed char *)g_sms_number_buf, 42, (VMWCHAR*)read_msg->message_data->number); 114 | 115 | // assume dcs = UCS2 116 | g_sms_content_buf = content; 117 | vm_chset_ucs2_to_ascii((signed char *)g_sms_content_buf, MAX_CONTENT_BUFFER, (VMWCHAR*)read_msg->message_data->content_buffer); 118 | 119 | VMUINT16 i,j = 0; 120 | VMUINT16 str_len; 121 | VMUINT8 str_num; 122 | 123 | str_len = strlen(g_sms_content_buf); 124 | str_num = str_len / 151 + 1; 125 | vm_log_info("str_len is %d", str_len); 126 | vm_log_info("str_num is %d", str_num); 127 | 128 | while(1) 129 | { 130 | msgIdMax ++; 131 | if(msgIdMax >= GSM_SMS_NUM_MAX)msgIdMax = GSM_SMS_NUM_MAX; 132 | 133 | for(i=0;i<(GSM_SMS_NUM_MAX - 1);i++) 134 | { 135 | strcpy(msgNumber[(GSM_SMS_NUM_MAX - 2 - i) + 1], msgNumber[(GSM_SMS_NUM_MAX - 2) - i]); 136 | strcpy(msgContent[(GSM_SMS_NUM_MAX - 2 - i) + 1],msgContent[(GSM_SMS_NUM_MAX - 2) - i]); 137 | } 138 | 139 | strcpy(msgNumber[0], (char*)g_sms_number_buf); 140 | if(j < (str_len - 1)) 141 | strncpy(msgContent[0], (char*)(g_sms_content_buf + j * 150), 150); 142 | else 143 | strncpy(msgContent[0], (char*)(g_sms_content_buf + j * 150), str_len - j * 150); 144 | 145 | j ++; 146 | if(j == str_num)break; 147 | } 148 | 149 | vm_log_info("save message"); 150 | sms_inbox_save(); 151 | vm_log_info("saved"); 152 | 153 | if (g_sms_new_message_cb) { 154 | g_sms_new_message_cb(g_sms_number_buf, g_sms_content_buf); 155 | //g_sms_new_message_cb(msgNumber[0], msgContent[0]); 156 | } 157 | vm_log_info("callback done"); 158 | } 159 | } 160 | else 161 | { 162 | vm_log_info("read msg failed"); 163 | } 164 | } 165 | } 166 | 167 | VMUINT8 gsm_sms_get_unread(void* userdata) 168 | { 169 | sms_unread_msg_struct *dest = (sms_unread_msg_struct*)userdata; 170 | VMINT16 message_id; 171 | vm_gsm_sms_read_message_data_t* message_data = NULL; 172 | VMWCHAR* content_buff; 173 | VMINT res; 174 | 175 | //message_id = vm_gsm_sms_get_message_id(VM_GSM_SMS_BOX_INBOX, 0); 176 | //dest -> id = message_id; 177 | message_id = dest->id; 178 | 179 | if(message_id >= 0) 180 | { 181 | // Allocates memory for the message data 182 | message_data = (vm_gsm_sms_read_message_data_t*)vm_calloc(sizeof(vm_gsm_sms_read_message_data_t)); 183 | if(message_data == NULL) 184 | { 185 | vm_log_info("sms read malloc message data fail"); 186 | return FALSE; 187 | } 188 | 189 | // Allocates memory for the content buffer of the message 190 | content_buff = (VMWCHAR*)vm_calloc((500+1)*sizeof(VMWCHAR)); 191 | if(content_buff == NULL) 192 | { 193 | vm_free(message_data); 194 | vm_log_info("sms read malloc content fail"); 195 | return FALSE; 196 | 197 | } 198 | message_data->content_buffer = content_buff; 199 | message_data->content_buffer_size = 500; 200 | 201 | // Reads the message 202 | res = vm_gsm_sms_read_message(message_id, VM_TRUE, message_data, sms_read_callback, NULL); 203 | //vm_log_info("vm_gsm_sms_read_message message_id is %d", message_id); 204 | 205 | if(res != VM_GSM_SMS_RESULT_OK) 206 | { 207 | vm_free(content_buff); 208 | vm_free(message_data); 209 | 210 | vm_log_info("register read callback fail"); 211 | return FALSE; 212 | } 213 | else 214 | { 215 | return TRUE; 216 | } 217 | } 218 | } 219 | 220 | VMUINT8 gsm_sms_read_available(VMINT16 msgID) 221 | { 222 | sms_unread_msg_struct msgRead; 223 | 224 | msgRead.id = msgID; 225 | gsm_sms_get_unread(&msgRead); 226 | if(msgRead.id < 0)return FALSE; 227 | 228 | return TRUE; 229 | } 230 | 231 | void sms_delete_callback(vm_gsm_sms_callback_t* callback_data){} 232 | 233 | VMUINT8 gsm_sms_delete(void) 234 | { 235 | VMINT16 message_num; 236 | VMINT16 message_id; 237 | 238 | message_num = vm_gsm_sms_get_box_size(VM_GSM_SMS_BOX_INBOX); 239 | //vm_log_info("VM_GSM_SMS_BOX_INBOX number is %d", message_num); 240 | message_id = vm_gsm_sms_get_message_id(VM_GSM_SMS_BOX_INBOX, message_num - 1); 241 | //vm_log_info("VM_GSM_SMS_BOX_INBOX id is %d", message_id); 242 | 243 | if(message_id >= 0) 244 | { 245 | vm_gsm_sms_delete_message(message_id, sms_delete_callback, NULL); 246 | return TRUE; 247 | } 248 | 249 | return FALSE; 250 | } 251 | 252 | VMINT gsm_sms_new_message_interrupt_proc(vm_gsm_sms_event_t* event_data) 253 | { 254 | vm_gsm_sms_event_new_sms_t* event_new_message_ptr; 255 | vm_gsm_sms_new_message_t* new_message_ptr = NULL; 256 | 257 | if(event_data->event_id == VM_GSM_SMS_EVENT_ID_SMS_NEW_MESSAGE) 258 | { 259 | event_new_message_ptr = (vm_gsm_sms_event_new_sms_t *)event_data->event_info; // Gets the event info. 260 | new_message_ptr = event_new_message_ptr->message_data; // Gets the message data. 261 | 262 | vm_log_info("custom_sms_new_message_interrupt_proc have got ready message"); 263 | gsm_sms_read_available(new_message_ptr->message_id); 264 | } 265 | 266 | return TRUE; 267 | } 268 | 269 | void gsm_sms_set_interrupt_event_handler(void) 270 | { 271 | VMINT res = 0; 272 | 273 | sms_inbox_open(); 274 | 275 | res = vm_gsm_sms_set_interrupt_event_handler(VM_GSM_SMS_EVENT_ID_SMS_NEW_MESSAGE, gsm_sms_new_message_interrupt_proc, NULL); 276 | 277 | if(res != VM_GSM_SMS_RESULT_OK) 278 | { 279 | vm_log_info("gsm sms set interrupt fail!"); 280 | } 281 | else 282 | { 283 | vm_log_info("gsm sms set interrupt success!"); 284 | } 285 | } 286 | 287 | VMUINT16 gsm_sms_get_list_number(void) 288 | { 289 | return msgIdMax; 290 | } 291 | 292 | char* gsm_sms_remote_number(VMUINT8 num) 293 | { 294 | if(num >= msgIdMax)return NULL; 295 | return msgNumber[num]; 296 | } 297 | 298 | char* gsm_sms_remote_content(VMUINT8 num) 299 | { 300 | if(num >= msgIdMax)return NULL; 301 | return msgContent[num]; 302 | } 303 | 304 | void sms_inbox_open() 305 | { 306 | unsigned long len; 307 | unsigned long i; 308 | msgIdMax = 0; 309 | 310 | file_open("sms_inbox.txt"); 311 | file_size("sms_inbox.txt", &len); 312 | 313 | if(len > 2) 314 | { 315 | char str_tmp[GSM_SMS_NUM_MAX*(42+151+5)]; 316 | file_read("sms_inbox.txt", str_tmp, len, 0); 317 | 318 | for(i=0; i= GSM_SMS_NUM_MAX)msgIdMax = GSM_SMS_NUM_MAX; 327 | } 328 | } 329 | } 330 | 331 | void sms_inbox_save() 332 | { 333 | int i; 334 | 335 | file_delete("sms_inbox.txt"); 336 | file_open("sms_inbox.txt"); 337 | 338 | char str[151]; 339 | for(i=0;i 3 | #include "ugui.h" 4 | #include "vmlog.h" 5 | #include "address_book.h" 6 | 7 | UG_WINDOW* g_prev_contact_window_ptr; 8 | UG_WINDOW g_contact_list_window; 9 | UG_WINDOW g_dial_window; 10 | 11 | uint8_t g_contact_first_visible = 0; 12 | char g_contact_items[4][40]; 13 | const char* g_dial_button_text[15] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#", "1", "0", "7" }; 14 | char g_outgoing_number[16] = { 15 | 0, 16 | }; 17 | int g_outgoing_number_length = 11; 18 | 19 | extern UG_WINDOW g_sms_info_window; 20 | extern UG_WINDOW g_sms_new_window; 21 | extern UG_WINDOW g_call_action_window; 22 | extern UG_WINDOW g_call_condition_window; 23 | extern char* g_sms_message; 24 | 25 | extern void calling_window_show(char* phone_number); 26 | extern void sms_template_window_show(); 27 | 28 | void contact_list_window_update() 29 | { 30 | int i; 31 | 32 | int number = book_get_number(); 33 | for(i = 0; i < 4; i++) { 34 | char* contact_string = NULL; 35 | unsigned index = i + g_contact_first_visible; 36 | if(index < number) { 37 | book_get_item(index, g_contact_items[i], sizeof(g_contact_items[i])); 38 | contact_string = g_contact_items[i]; 39 | } 40 | 41 | UG_ButtonSetText(&g_contact_list_window, i, contact_string); 42 | } 43 | } 44 | 45 | void contact_list_window_callback(UG_MESSAGE* msg) 46 | { 47 | if(msg->type == MSG_TYPE_OBJECT) { 48 | if(msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 49 | unsigned index; 50 | int contact_number = book_get_number(); 51 | 52 | switch(msg->sub_id) { 53 | case 0: 54 | case 1: 55 | case 2: 56 | case 3: 57 | index = msg->sub_id + g_contact_first_visible; 58 | if(index < contact_number) { 59 | char* phone = book_get_item_number(index); 60 | g_outgoing_number_length = strlen(phone); 61 | strcpy(g_outgoing_number, phone); 62 | if(g_prev_contact_window_ptr == &g_sms_new_window) { 63 | UG_ButtonSetText(&g_sms_new_window, 5, g_outgoing_number); 64 | UG_WindowShow(&g_sms_new_window); 65 | } else if(g_prev_contact_window_ptr == &g_call_action_window) { 66 | strcpy(UG_ButtonGetText(&g_call_action_window, 2), g_outgoing_number); 67 | UG_WindowShow(&g_call_action_window); 68 | } else if(g_prev_contact_window_ptr == &g_call_condition_window) { 69 | strcpy(UG_ButtonGetText(&g_call_condition_window, 2), g_outgoing_number); 70 | UG_WindowShow(&g_call_condition_window); 71 | } else { 72 | calling_window_show(g_outgoing_number); 73 | } 74 | } 75 | break; 76 | case 4: // back 77 | UG_WindowShow(g_prev_contact_window_ptr); 78 | break; 79 | case 5: // down 80 | if(g_contact_first_visible < (contact_number - 1)) { 81 | g_contact_first_visible++; 82 | contact_list_window_update(); 83 | } 84 | break; 85 | case 6: // up 86 | if(g_contact_first_visible > 0) { 87 | g_contact_first_visible--; 88 | contact_list_window_update(); 89 | } 90 | break; 91 | case 7: // dial 92 | dial_window_show(); 93 | break; 94 | default: 95 | break; 96 | } 97 | } 98 | } 99 | } 100 | 101 | void contact_list_window_create(void) 102 | { 103 | static UG_BUTTON buttons[9]; 104 | static UG_OBJECT objects[9]; 105 | char* actions[] = { "1", "4", "3", "B" }; 106 | int i = 0; 107 | 108 | UG_WindowCreate(&g_contact_list_window, objects, sizeof(objects) / sizeof(*objects), contact_list_window_callback); 109 | UG_WindowSetStyle(&g_contact_list_window, WND_STYLE_2D); 110 | 111 | for(i = 0; i < 4; i++) { 112 | UG_ButtonCreate(&g_contact_list_window, buttons + i, i, 0, 40 * i + 40, 239, 40 * (i + 1) + 40 - 1); 113 | UG_ButtonSetFont(&g_contact_list_window, i, &FONT_SIZE20); 114 | UG_ButtonSetStyle(&g_contact_list_window, i, BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 115 | 116 | UG_ButtonSetAlignment(&g_contact_list_window, i, ALIGN_CENTER_LEFT); 117 | UG_ButtonSetHSpace(&g_contact_list_window, i, 8); 118 | } 119 | 120 | for(i = 0; i < 4; i++) { 121 | int index = 4 + i; 122 | UG_ButtonCreate(&g_contact_list_window, buttons + index, index, 60 * i, 200, 60 * i + 60 - 1, 239); 123 | UG_ButtonSetFont(&g_contact_list_window, index, &FONT_ICON24); 124 | UG_ButtonSetText(&g_contact_list_window, index, actions[i]); 125 | UG_ButtonSetStyle(&g_contact_list_window, index, BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 126 | } 127 | 128 | UG_ButtonCreate(&g_contact_list_window, buttons + 8, 8, 0, 0, 239, 39); 129 | UG_ButtonSetFont(&g_contact_list_window, 8, &FONT_SIZE20); 130 | UG_ButtonSetText(&g_contact_list_window, 8, "Contacts"); 131 | UG_ButtonSetStyle(&g_contact_list_window, 8, BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 132 | UG_ButtonSetBackColor(&g_contact_list_window, 8, 0x000000); 133 | 134 | book_open(); 135 | dial_window_create(); 136 | } 137 | 138 | void contact_list_window_show() 139 | { 140 | g_prev_contact_window_ptr = UG_GetActiveWindow(); 141 | 142 | g_contact_first_visible = 0; 143 | contact_list_window_update(); 144 | UG_WindowShow(&g_contact_list_window); 145 | } 146 | 147 | static void dial_window_callback(UG_MESSAGE* msg) 148 | { 149 | if(msg->type == MSG_TYPE_OBJECT) { 150 | if(msg->id == OBJ_TYPE_BUTTON && msg->event == OBJ_EVENT_RELEASED) { 151 | switch(msg->sub_id) { 152 | case 15: // text 153 | break; 154 | case 12: // return 155 | UG_WindowShow(&g_contact_list_window); 156 | break; 157 | case 13: // call or send sms 158 | if(g_prev_contact_window_ptr == &g_sms_new_window) { 159 | UG_ButtonSetText(&g_sms_new_window, 5, g_outgoing_number); 160 | UG_WindowShow(&g_sms_new_window); 161 | } else if(g_prev_contact_window_ptr == &g_call_action_window) { 162 | strcpy(UG_ButtonGetText(&g_call_action_window, 2), g_outgoing_number); 163 | UG_WindowShow(&g_call_action_window); 164 | } else if(g_prev_contact_window_ptr == &g_call_condition_window) { 165 | strcpy(UG_ButtonGetText(&g_call_condition_window, 2), g_outgoing_number); 166 | UG_WindowShow(&g_call_condition_window); 167 | } else { 168 | calling_window_show(g_outgoing_number); 169 | } 170 | break; 171 | case 14: // delete 172 | if(g_outgoing_number_length > 0) { 173 | g_outgoing_number_length--; 174 | g_outgoing_number[g_outgoing_number_length] = '\0'; 175 | UG_ButtonSetText(&g_dial_window, 15, g_outgoing_number); 176 | } 177 | break; 178 | default: 179 | if(g_outgoing_number_length < (sizeof(g_outgoing_number) - 1)) { 180 | int index = msg->sub_id; 181 | g_outgoing_number[g_outgoing_number_length] = *g_dial_button_text[index]; 182 | UG_ButtonSetText(&g_dial_window, 15, g_outgoing_number); 183 | g_outgoing_number_length++; 184 | g_outgoing_number[g_outgoing_number_length] = '\0'; 185 | } 186 | } 187 | } 188 | } 189 | } 190 | 191 | void dial_window_create(void) 192 | { 193 | static UG_BUTTON buttons[16]; 194 | static UG_OBJECT objects[16]; 195 | int i = 0; 196 | int j = 0; 197 | 198 | UG_WindowCreate(&g_dial_window, objects, 16, dial_window_callback); 199 | UG_WindowSetStyle(&g_dial_window, WND_STYLE_2D); 200 | 201 | for(i = 0; i < 4; i++) { 202 | for(j = 0; j < 3; j++) { 203 | int index = i * 3 + j; 204 | UG_ButtonCreate( 205 | &g_dial_window, buttons + index, index, 80 * j, 40 * (i + 1), 80 * (j + 1) - 1, 40 * (i + 2) - 1); 206 | UG_ButtonSetFont(&g_dial_window, index, &FONT_SIZE20); 207 | UG_ButtonSetText(&g_dial_window, index, g_dial_button_text[index]); 208 | UG_ButtonSetStyle(&g_dial_window, index, BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 209 | } 210 | } 211 | 212 | for(j = 0; j < 3; j++) { 213 | int index = 4 * 3 + j; 214 | UG_ButtonCreate( 215 | &g_dial_window, buttons + index, index, 80 * j, 40 * (i + 1), 80 * (j + 1) - 1, 40 * (i + 2) - 1); 216 | UG_ButtonSetFont(&g_dial_window, index, &FONT_ICON24); 217 | UG_ButtonSetText(&g_dial_window, index, g_dial_button_text[index]); 218 | UG_ButtonSetStyle(&g_dial_window, index, BTN_STYLE_2D | BTN_STYLE_TOGGLE_COLORS | BTN_STYLE_NO_BORDERS); 219 | } 220 | 221 | UG_ButtonCreate(&g_dial_window, buttons + 15, 15, 0, 0, 239, 39); 222 | UG_ButtonSetFont(&g_dial_window, 15, &FONT_SIZE20); 223 | UG_ButtonSetText(&g_dial_window, 15, g_outgoing_number); 224 | UG_ButtonSetStyle(&g_dial_window, 15, BTN_STYLE_2D | BTN_STYLE_NO_BORDERS); 225 | UG_ButtonSetBackColor(&g_dial_window, 15, 0); // 0x37474f); 226 | 227 | // UG_ButtonSetBackColor(&g_dial_window, CALL_BTN_ID, 0x4CAF50); 228 | } 229 | 230 | void dial_window_show(void) 231 | { 232 | char* icon; 233 | if(g_prev_contact_window_ptr == &g_sms_info_window) { 234 | icon = "E"; // sms 235 | } else if(g_prev_contact_window_ptr == &g_call_condition_window || 236 | g_prev_contact_window_ptr == &g_call_action_window || g_prev_contact_window_ptr == &g_sms_new_window) { 237 | icon = ":"; // ok 238 | } else { 239 | icon = "0"; // call 240 | } 241 | UG_ButtonSetText(&g_dial_window, 13, icon); 242 | 243 | g_outgoing_number[0] = '\0'; 244 | g_outgoing_number_length = 0; 245 | UG_ButtonSetText(&g_dial_window, 15, g_outgoing_number); 246 | 247 | UG_WindowShow(&g_dial_window); 248 | } 249 | -------------------------------------------------------------------------------- /RePhone_Create_Source_Code/.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 79 | 80 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | --------------------------------------------------------------------------------