2003-07-24 10:03:33 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
2003-08-08 01:50:51 +00:00
|
|
|
* (based upon 1.1 by calpefrosch) updated by www.HuwSy.ukhackers.net
|
2003-07-24 10:03:33 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2002
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2003-07-24 10:03:33 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "plugin.h"
|
|
|
|
|
|
|
|
#include <timefuncs.h>
|
2009-08-05 14:29:29 +00:00
|
|
|
#include "lib/playback_control.h"
|
2009-11-04 13:03:42 +00:00
|
|
|
#include "lib/configfile.h"
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2020-07-15 23:40:55 +00:00
|
|
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
2008-10-25 16:34:15 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_OFF
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_MODE
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_REC
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
|
|
|
#define CALENDAR_QUIT (BUTTON_SELECT|BUTTON_MENU)
|
2008-10-25 17:03:38 +00:00
|
|
|
#define CALENDAR_SELECT (BUTTON_SELECT|BUTTON_REL)
|
2008-10-25 16:34:15 +00:00
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_SCROLL_FWD
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_SCROLL_BACK
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_PLAY
|
2008-10-25 17:03:38 +00:00
|
|
|
#define CALENDAR_PREV_MONTH (BUTTON_MENU|BUTTON_REL)
|
2008-10-25 16:34:15 +00:00
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
2008-10-26 12:47:43 +00:00
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_PLAY
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_REC
|
2008-10-25 16:34:15 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_DOWN
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_UP
|
|
|
|
|
2009-04-10 17:28:26 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
2008-10-25 16:34:15 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_SCROLL_FWD
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_SCROLL_BACK
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_UP
|
|
|
|
|
2009-04-10 17:28:26 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZE_PAD
|
|
|
|
#define CALENDAR_QUIT (BUTTON_HOME|BUTTON_REPEAT)
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_SCROLL_FWD
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_SCROLL_BACK
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_UP
|
|
|
|
|
2009-12-14 21:51:42 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_C200_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SANSA_M200_PAD)
|
2008-10-25 16:34:15 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_SCROLL_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_SCROLL_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_FF
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_REW
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_BACK
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_PREV
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == MROBE100_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH (BUTTON_MENU|BUTTON_DOWN)
|
|
|
|
#define CALENDAR_PREV_MONTH (BUTTON_MENU|BUTTON_UP)
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_RC_REC
|
|
|
|
#define CALENDAR_SELECT BUTTON_RC_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_RC_VOL_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_RC_VOL_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RC_FF
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_RC_REW
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_RC_MODE
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_RC_MENU
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif (CONFIG_KEYPAD == COWON_D2_PAD)
|
2008-10-25 16:34:15 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_CENTER
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_BOTTOMRIGHT
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_BOTTOMLEFT
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "menu"
|
2008-10-25 16:34:15 +00:00
|
|
|
|
2009-12-14 21:51:42 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_BACK
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_CUSTOM
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_PLAY
|
|
|
|
|
2014-03-21 21:16:02 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_MENU
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_BACK
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "play"
|
2014-03-21 21:16:02 +00:00
|
|
|
|
2009-01-24 22:41:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_DOWN
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_UP
|
|
|
|
|
2010-11-02 03:29:16 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_PREV
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_DOWN
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_UP
|
|
|
|
|
2009-12-02 01:56:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_PREV
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_DOWN
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_UP
|
|
|
|
|
2009-04-07 23:41:44 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX747_PAD)
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_MENU
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_VOL_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_BOTTOMRIGHT
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_BOTTOMLEFT
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "menu"
|
2009-04-07 23:41:44 +00:00
|
|
|
|
2009-08-31 21:11:32 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX777_PAD)
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
|
2009-04-21 04:24:16 +00:00
|
|
|
#elif CONFIG_KEYPAD == MROBE500_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
|
2016-01-23 14:54:08 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH92X_PAD
|
2015-07-19 23:50:26 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_REW
|
2009-08-04 03:08:32 +00:00
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
2015-07-19 23:50:26 +00:00
|
|
|
#define CALENDAR_NEXT_MONTH (BUTTON_FFWD|BUTTON_DOWN)
|
|
|
|
#define CALENDAR_PREV_MONTH (BUTTON_FFWD|BUTTON_UP)
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH820_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_REW
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH (BUTTON_REC|BUTTON_DOWN)
|
|
|
|
#define CALENDAR_PREV_MONTH (BUTTON_REC|BUTTON_UP)
|
2009-08-04 03:08:32 +00:00
|
|
|
|
2010-02-13 15:46:34 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_REC
|
|
|
|
#define CALENDAR_SELECT BUTTON_OK
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_PREV
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_PLAY
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_MENU
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "FFWD"
|
2010-02-13 15:46:34 +00:00
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
|
|
|
#define CALENDAR_QUIT (BUTTON_REC|BUTTON_PLAY)
|
2010-11-02 10:44:34 +00:00
|
|
|
#define CALENDAR_SELECT BUTTON_FUNC
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_FF
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_REW
|
2010-04-26 21:40:00 +00:00
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_VOL_DOWN
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_PLAY
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_REC
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "func"
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD300_PAD
|
2012-02-02 13:42:42 +00:00
|
|
|
#define CALENDAR_QUIT (BUTTON_MENU|BUTTON_REPEAT)
|
2010-11-30 10:52:14 +00:00
|
|
|
#define CALENDAR_SELECT BUTTON_ENTER
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_FF
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_REW
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_UP
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_DOWN
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_PLAY
|
2012-02-02 13:42:42 +00:00
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_REC
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "enter"
|
2010-11-30 10:52:14 +00:00
|
|
|
|
2011-10-02 16:04:45 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
2012-02-24 22:32:09 +00:00
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
2011-10-02 16:04:45 +00:00
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_PLAYPAUSE
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_BACK
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "select"
|
2011-10-02 16:04:45 +00:00
|
|
|
|
2011-11-16 14:08:01 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_CONNECT_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_UP
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_DOWN
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_PREV
|
|
|
|
|
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system,
but is the only application. It therefore can implement lots of stuff that
native targets also implement, while leveraging the underlying linux kernel.
The port is quite advanced. User interface, audio playback, plugins work
mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page).
Included in utils/ypr0tools are scripts and programs required to generate
a patched firmware. The patched firmware has the rootfs modified to load
Rockbox. It includes a early/safe USB mode.
This port needs a new toolchain, one that includes glibc headers and libraries.
rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may
also work.
Most of the initial effort is done by Lorenzo Miori and others (on ABI),
including reverse engineering and patching of the original firmware,
initial drivers, and more. Big thanks to you.
Flyspray: FS#12348
Author: Lorenzo Miori, myself
Merry christmas to ypr0 owners! :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
2011-12-24 11:56:46 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_BACK
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_POWER
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_USER
|
|
|
|
|
2012-03-23 18:32:50 +00:00
|
|
|
#elif CONFIG_KEYPAD == HM60X_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH (BUTTON_RIGHT|BUTTON_POWER)
|
|
|
|
#define CALENDAR_PREV_MONTH (BUTTON_LEFT|BUTTON_POWER)
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "select"
|
2012-03-23 18:32:50 +00:00
|
|
|
|
2012-04-06 16:17:27 +00:00
|
|
|
#elif CONFIG_KEYPAD == HM801_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_PREV
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "select"
|
2012-04-06 16:17:27 +00:00
|
|
|
|
2014-06-30 18:24:15 +00:00
|
|
|
#elif CONFIG_KEYPAD == SONY_NWZ_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_BACK
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_MONTH (BUTTON_POWER|BUTTON_DOWN)
|
|
|
|
#define CALENDAR_PREV_MONTH (BUTTON_POWER|BUTTON_UP)
|
|
|
|
|
2014-07-17 08:40:17 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVE_ZEN_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_BACK
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_SHORTCUT
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_MENU
|
|
|
|
|
2014-08-30 11:15:53 +00:00
|
|
|
#elif CONFIG_KEYPAD == DX50_PAD
|
|
|
|
#define CALENDAR_QUIT (BUTTON_POWER|BUTTON_REL)
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_VOL_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_BOTTOMRIGHT
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_BOTTOMLEFT
|
2015-12-27 17:14:41 +00:00
|
|
|
#define CALENDAR_EVENT_MENU_NAME "play"
|
2014-08-30 11:15:53 +00:00
|
|
|
|
2018-02-22 22:42:29 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI2_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_MENU
|
|
|
|
#define CALENDAR_EVENT_MENU_NAME "menu"
|
|
|
|
|
2018-03-02 20:53:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == AGPTEK_ROCKER_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_MONTH (BUTTON_VOLDOWN)
|
|
|
|
#define CALENDAR_PREV_MONTH (BUTTON_VOLUP)
|
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == XDUOO_X3_PAD || CONFIG_KEYPAD == XDUOO_X3II_PAD || CONFIG_KEYPAD == XDUOO_X20_PAD
|
2018-11-05 12:01:55 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
2020-10-03 22:17:11 +00:00
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_OPTION
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_HOME
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_PREV
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
|
|
|
|
|
2021-02-27 22:07:37 +00:00
|
|
|
#elif CONFIG_KEYPAD == FIIO_M3K_LINUX_PAD
|
2020-10-03 22:17:11 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
2018-11-05 12:01:55 +00:00
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_OPTION
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_HOME
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_PREV
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
|
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == IHIFI_770_PAD || CONFIG_KEYPAD == IHIFI_800_PAD
|
2018-06-29 20:09:28 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
|
|
|
#define CALENDAR_NEXT_WEEK (BUTTON_POWER | BUTTON_VOL_DOWN)
|
|
|
|
#define CALENDAR_PREV_WEEK (BUTTON_POWER | BUTTON_VOL_UP)
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_PREV
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_DOWN
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_UP
|
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == EROSQ_PAD
|
2018-06-29 20:09:28 +00:00
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_PLAY
|
2020-10-08 13:47:40 +00:00
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_NEXT
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_PREV
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_SCROLL_FWD
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_SCROLL_BACK
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
|
2018-06-29 20:09:28 +00:00
|
|
|
|
2021-02-27 22:08:58 +00:00
|
|
|
#elif CONFIG_KEYPAD == FIIO_M3K_PAD
|
|
|
|
#define CALENDAR_QUIT BUTTON_POWER
|
|
|
|
#define CALENDAR_SELECT BUTTON_SELECT
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_DOWN
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_UP
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_LEFT
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_RIGHT
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
|
|
|
|
|
2021-05-23 16:30:58 +00:00
|
|
|
#elif CONFIG_KEYPAD == SHANLING_Q1_PAD
|
|
|
|
/* use touchscreen */
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
#else
|
|
|
|
#error "No keypad setting."
|
|
|
|
#endif
|
|
|
|
|
2009-04-21 04:24:16 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
#ifndef CALENDAR_QUIT
|
|
|
|
#define CALENDAR_QUIT BUTTON_MIDLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef CALENDAR_SELECT
|
|
|
|
#define CALENDAR_SELECT BUTTON_CENTER
|
|
|
|
#endif
|
|
|
|
#ifndef CALENDAR_NEXT_DAY
|
|
|
|
#define CALENDAR_NEXT_DAY BUTTON_TOPLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef CALENDAR_PREV_DAY
|
|
|
|
#define CALENDAR_PREV_DAY BUTTON_BOTTOMLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef CALENDAR_NEXT_WEEK
|
|
|
|
#define CALENDAR_NEXT_WEEK BUTTON_TOPMIDDLE
|
|
|
|
#endif
|
|
|
|
#ifndef CALENDAR_PREV_WEEK
|
|
|
|
#define CALENDAR_PREV_WEEK BUTTON_BOTTOMMIDDLE
|
|
|
|
#endif
|
|
|
|
#ifndef CALENDAR_NEXT_MONTH
|
|
|
|
#define CALENDAR_NEXT_MONTH BUTTON_TOPRIGHT
|
|
|
|
#endif
|
|
|
|
#ifndef CALENDAR_PREV_MONTH
|
|
|
|
#define CALENDAR_PREV_MONTH BUTTON_BOTTOMRIGHT
|
|
|
|
#endif
|
2015-12-27 17:14:41 +00:00
|
|
|
#ifndef CALENDAR_EVENT_MENU_NAME
|
|
|
|
#define CALENDAR_EVENT_MENU_NAME "select"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CALENDAR_EVENT_MENU_NAME
|
|
|
|
#define CALENDAR_EVENT_MENU_NAME "right"
|
2009-04-21 04:24:16 +00:00
|
|
|
#endif
|
|
|
|
|
2011-03-02 23:43:54 +00:00
|
|
|
#define MEMO_FILE PLUGIN_APPS_DATA_DIR "/.memo"
|
|
|
|
#define TEMP_FILE PLUGIN_APPS_DATA_DIR "/~temp"
|
2009-08-29 15:38:08 +00:00
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
#define X_OFFSET ((LCD_WIDTH%7)/2)
|
|
|
|
#if LCD_HEIGHT <= 80
|
|
|
|
#define Y_OFFSET 1
|
|
|
|
#else
|
|
|
|
#define Y_OFFSET 4
|
|
|
|
#endif
|
|
|
|
#define CELL_WIDTH (LCD_WIDTH / 7)
|
|
|
|
#define CELL_HEIGHT (LCD_HEIGHT / 7)
|
|
|
|
|
2009-11-04 13:03:42 +00:00
|
|
|
#define CFG_FILE "calendar.cfg"
|
2009-12-14 21:51:42 +00:00
|
|
|
struct info {
|
|
|
|
int first_wday;
|
|
|
|
#if (CONFIG_RTC == 0)
|
|
|
|
int last_mon;
|
|
|
|
int last_year;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
static struct info info = { .first_wday = 0 }, old_info;
|
2009-11-04 13:03:42 +00:00
|
|
|
static struct configdata config[] = {
|
2009-12-14 21:51:42 +00:00
|
|
|
{ TYPE_INT, 0, 6, { .int_p = &(info.first_wday) }, "first wday", NULL },
|
|
|
|
#if (CONFIG_RTC == 0)
|
|
|
|
{ TYPE_INT, 1, 12, { .int_p = &(info.last_mon) }, "last mon", NULL },
|
|
|
|
{ TYPE_INT, 1, 3000, { .int_p = &(info.last_year) }, "last year", NULL },
|
|
|
|
#endif
|
2009-11-04 13:03:42 +00:00
|
|
|
};
|
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
static bool leap_year;
|
2008-10-24 08:40:48 +00:00
|
|
|
/* days_in_month[][0] is for December */
|
2008-10-04 11:35:53 +00:00
|
|
|
static const int days_in_month[2][13] = {
|
2008-10-24 08:40:48 +00:00
|
|
|
{31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
|
|
|
|
{31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
|
2003-07-24 10:03:33 +00:00
|
|
|
};
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
static const char *dayname_long[7] = {"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
|
|
|
|
static const char *dayname_short[7] = {"M","T","W","T","F","S","S"};
|
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
struct shown {
|
|
|
|
int mday; /* day of the month */
|
|
|
|
int mon; /* month */
|
|
|
|
int year; /* year since 1900 */
|
|
|
|
int wday; /* day of the week */
|
|
|
|
int firstday; /* first (w)day of month */
|
|
|
|
int lastday; /* last (w)day of month */
|
|
|
|
};
|
2003-11-20 00:47:16 +00:00
|
|
|
|
|
|
|
static bool use_system_font = false;
|
|
|
|
|
2004-07-27 06:19:01 +00:00
|
|
|
static bool been_in_usb_mode = false;
|
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
/* leap year -- account for gregorian reformation in 1752 */
|
|
|
|
static int is_leap_year(int yr)
|
|
|
|
{
|
|
|
|
return ((yr) <= 1752 ? !((yr) % 4) : \
|
2009-10-20 15:13:57 +00:00
|
|
|
(!((yr) % 4) && ((yr) % 100)) || !((yr) % 400)) ? 1:0 ;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
|
2009-08-03 16:30:08 +00:00
|
|
|
/* searches the weekday of the first day in month,
|
2003-07-24 12:22:10 +00:00
|
|
|
* relative to the given values */
|
2003-07-24 10:03:33 +00:00
|
|
|
static int calc_weekday( struct shown *shown )
|
|
|
|
{
|
|
|
|
return ( shown->wday + 36 - shown->mday ) % 7 ;
|
|
|
|
}
|
|
|
|
|
2009-12-14 21:51:42 +00:00
|
|
|
#if (CONFIG_RTC == 0)
|
|
|
|
/* from timefunc.c */
|
|
|
|
static void my_set_day_of_week(struct shown *shown)
|
|
|
|
{
|
|
|
|
int y = shown->year;
|
|
|
|
int d = shown->mday;
|
|
|
|
int m = shown->mon-1;
|
|
|
|
static const char mo[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
|
|
|
|
|
|
|
|
if(m == 0 || m == 1) y--;
|
|
|
|
shown->wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7 - 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-10-03 09:33:42 +00:00
|
|
|
static void calendar_init(struct shown *shown)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
int w, h;
|
2007-03-16 23:47:03 +00:00
|
|
|
#if CONFIG_RTC
|
2003-07-24 12:22:10 +00:00
|
|
|
struct tm *tm;
|
|
|
|
#endif
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->lcd_getstringsize("A", &w, &h);
|
2003-07-24 10:03:33 +00:00
|
|
|
if ( ((w * 14) > LCD_WIDTH) || ((h * 7) > LCD_HEIGHT) )
|
2003-11-20 00:47:16 +00:00
|
|
|
{
|
|
|
|
use_system_font = true;
|
|
|
|
}
|
2007-03-16 23:47:03 +00:00
|
|
|
#if CONFIG_RTC
|
2003-07-24 10:03:33 +00:00
|
|
|
tm = rb->get_time();
|
2009-10-03 09:33:42 +00:00
|
|
|
shown->mday = tm->tm_mday;
|
2009-10-20 15:13:57 +00:00
|
|
|
shown->mon = tm->tm_mon + 1;
|
|
|
|
shown->year = 2000 + (tm->tm_year%100);
|
|
|
|
shown->wday = tm->tm_wday - 1;
|
2009-12-14 21:51:42 +00:00
|
|
|
#else
|
|
|
|
#define S100(x) 1 ## x
|
|
|
|
#define C2DIG2DEC(x) (S100(x)-100)
|
|
|
|
if(info.last_mon == 0 || info.last_year == 0)
|
|
|
|
{
|
|
|
|
shown->mon = C2DIG2DEC(MONTH);
|
|
|
|
shown->year = YEAR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shown->mon = info.last_mon;
|
|
|
|
shown->year = info.last_year;
|
|
|
|
}
|
|
|
|
shown->mday = 1;
|
|
|
|
my_set_day_of_week(shown);
|
2003-07-24 10:03:33 +00:00
|
|
|
#endif
|
|
|
|
shown->firstday = calc_weekday(shown);
|
|
|
|
leap_year = is_leap_year(shown->year);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_headers(void)
|
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
int i, w, h;
|
2008-10-25 16:34:15 +00:00
|
|
|
int x = X_OFFSET;
|
2009-11-04 13:03:42 +00:00
|
|
|
int wday;
|
2009-10-20 15:13:57 +00:00
|
|
|
const char **dayname = dayname_long;
|
2008-10-25 16:34:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->lcd_getstringsize(dayname[i], &w, &h);
|
2008-10-25 16:34:15 +00:00
|
|
|
if (w > CELL_WIDTH)
|
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
dayname = dayname_short;
|
2008-10-25 16:34:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-14 21:51:42 +00:00
|
|
|
wday = info.first_wday;
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->lcd_getstringsize("A", &w, &h);
|
2008-10-04 11:35:53 +00:00
|
|
|
for (i = 0; i < 7; i++)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2009-11-04 13:03:42 +00:00
|
|
|
if (wday >= 7) wday = 0;
|
|
|
|
rb->lcd_putsxy(x, 0, dayname[wday++]);
|
2008-10-25 16:34:15 +00:00
|
|
|
x += CELL_WIDTH;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->lcd_hline(0, LCD_WIDTH-1, h);
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
|
2008-10-04 11:35:53 +00:00
|
|
|
static bool day_has_memo[32];
|
|
|
|
static bool wday_has_memo[7];
|
2003-07-24 10:03:33 +00:00
|
|
|
static void draw_calendar(struct shown *shown)
|
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
int w, h;
|
|
|
|
int x, y, pos, days_per_month, j;
|
2009-11-04 13:03:42 +00:00
|
|
|
int wday;
|
2008-10-24 08:40:48 +00:00
|
|
|
const char *monthname[] = {
|
2009-08-03 16:30:08 +00:00
|
|
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
|
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
|
|
|
};
|
2008-10-25 16:34:15 +00:00
|
|
|
if(use_system_font)
|
2009-10-20 15:13:57 +00:00
|
|
|
{
|
2008-10-25 16:34:15 +00:00
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2009-10-20 15:13:57 +00:00
|
|
|
}
|
|
|
|
rb->lcd_getstringsize("A", &w, &h);
|
2003-07-24 10:03:33 +00:00
|
|
|
rb->lcd_clear_display();
|
|
|
|
draw_headers();
|
2009-11-04 13:03:42 +00:00
|
|
|
wday = shown->firstday;
|
2009-12-14 21:51:42 +00:00
|
|
|
pos = wday + 7 - info.first_wday;
|
2009-11-04 13:03:42 +00:00
|
|
|
if (pos >= 7) pos -= 7;
|
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
days_per_month = days_in_month[leap_year][shown->mon];
|
2008-10-25 16:34:15 +00:00
|
|
|
x = X_OFFSET + (pos * CELL_WIDTH);
|
|
|
|
y = Y_OFFSET + h;
|
|
|
|
for (j = 1; j <= days_per_month; j++)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
|
|
|
if (shown->mday == j)
|
|
|
|
{
|
2005-06-24 22:33:21 +00:00
|
|
|
rb->lcd_set_drawmode(DRMODE_SOLID);
|
2008-10-25 16:34:15 +00:00
|
|
|
rb->lcd_fillrect(x, y - 1, CELL_WIDTH - 1, CELL_HEIGHT);
|
|
|
|
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
2009-11-04 13:03:42 +00:00
|
|
|
shown->wday = wday;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
2008-10-25 16:34:15 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
rb->lcd_set_drawmode(DRMODE_SOLID);
|
|
|
|
}
|
2010-08-28 21:46:45 +00:00
|
|
|
if ( (day_has_memo[j]) || (wday_has_memo[wday]) )
|
|
|
|
rb->lcd_putsxyf(x, y, "%02d.", j);
|
|
|
|
else
|
|
|
|
rb->lcd_putsxyf(x, y, "%02d", j);
|
2008-10-25 16:34:15 +00:00
|
|
|
x += CELL_WIDTH;
|
2009-11-04 13:03:42 +00:00
|
|
|
wday++;
|
|
|
|
if (wday >= 7)
|
|
|
|
wday = 0;
|
2003-07-24 10:03:33 +00:00
|
|
|
pos++;
|
|
|
|
if (pos >= 7)
|
|
|
|
{
|
|
|
|
pos = 0;
|
2008-10-25 16:34:15 +00:00
|
|
|
x = X_OFFSET;
|
|
|
|
y += CELL_HEIGHT;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-04 13:03:42 +00:00
|
|
|
shown->lastday = wday;
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->lcd_set_drawmode(DRMODE_SOLID);
|
|
|
|
rb->lcd_vline(LCD_WIDTH-w*8-10, LCD_HEIGHT-h-3, LCD_HEIGHT-1);
|
|
|
|
rb->lcd_hline(LCD_WIDTH-w*8-10, LCD_WIDTH-1, LCD_HEIGHT-h-3);
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf(LCD_WIDTH-w*8-8, LCD_HEIGHT-h-1, "%s %04d",
|
2009-10-20 15:13:57 +00:00
|
|
|
monthname[shown->mon-1], shown->year);
|
2003-07-24 10:03:33 +00:00
|
|
|
rb->lcd_update();
|
|
|
|
}
|
|
|
|
|
2008-10-24 08:40:48 +00:00
|
|
|
#define MAX_CHAR_MEMO_LEN 64
|
|
|
|
#define MAX_MEMOS_IN_A_MONTH 128
|
2003-07-24 10:03:33 +00:00
|
|
|
struct memo {
|
|
|
|
char message[MAX_CHAR_MEMO_LEN];
|
|
|
|
int day;
|
|
|
|
int month;
|
|
|
|
int file_pointer_start;
|
|
|
|
int file_pointer_end;
|
|
|
|
int year;
|
|
|
|
int wday;
|
|
|
|
int type;
|
|
|
|
} memos[MAX_MEMOS_IN_A_MONTH];
|
|
|
|
static int pointer_array[MAX_MEMOS_IN_A_MONTH];
|
|
|
|
static int memos_in_memory = 0;
|
|
|
|
static int memos_in_shown_memory = 0;
|
2004-05-08 20:05:29 +00:00
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
static void load_memo(struct shown *shown)
|
|
|
|
{
|
2009-08-03 16:30:08 +00:00
|
|
|
int k, fp;
|
2003-07-24 10:03:33 +00:00
|
|
|
bool exit = false;
|
2004-05-08 20:05:29 +00:00
|
|
|
char temp_memo1[2];
|
|
|
|
char temp_memo2[3];
|
|
|
|
char temp_memo4[5];
|
2008-10-24 08:40:48 +00:00
|
|
|
temp_memo1[1] = 0;
|
|
|
|
temp_memo2[2] = 0;
|
|
|
|
temp_memo4[4] = 0;
|
2003-07-24 10:03:33 +00:00
|
|
|
for (k = 1; k < 32; k++)
|
|
|
|
day_has_memo[k] = false;
|
|
|
|
for (k = 0; k < 7; k++)
|
|
|
|
wday_has_memo[k] = false;
|
|
|
|
memos_in_memory = 0;
|
2009-08-29 15:38:08 +00:00
|
|
|
fp = rb->open(MEMO_FILE, O_RDONLY);
|
2003-07-24 10:03:33 +00:00
|
|
|
if (fp > -1)
|
|
|
|
{
|
|
|
|
rb->lseek(fp, 0, SEEK_SET);
|
|
|
|
while (!exit)
|
|
|
|
{
|
2009-08-03 16:30:08 +00:00
|
|
|
bool load_to_memory;
|
2009-10-20 15:13:57 +00:00
|
|
|
struct memo *memo = &memos[memos_in_memory];
|
|
|
|
rb->memset(memo, 0, sizeof(*memo));
|
|
|
|
memo->file_pointer_start = rb->lseek(fp, 0, SEEK_CUR);
|
2004-05-08 20:05:29 +00:00
|
|
|
if (rb->read(fp, temp_memo2, 2) == 2)
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->day = rb->atoi(temp_memo2);
|
2004-05-08 20:05:29 +00:00
|
|
|
if (rb->read(fp, temp_memo2, 2) == 2)
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->month = rb->atoi(temp_memo2);
|
2004-05-08 20:05:29 +00:00
|
|
|
if (rb->read(fp, temp_memo4, 4) == 4)
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->year = rb->atoi(temp_memo4);
|
2004-05-08 20:05:29 +00:00
|
|
|
if (rb->read(fp, temp_memo1, 1) == 1)
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->wday = rb->atoi(temp_memo1);
|
2004-05-08 20:05:29 +00:00
|
|
|
if (rb->read(fp, temp_memo1, 1) == 1)
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->type = rb->atoi(temp_memo1);
|
|
|
|
load_to_memory = ((memo->type < 2) ||
|
|
|
|
((memo->type == 2) &&
|
|
|
|
(memo->month == shown->mon)) ||
|
|
|
|
((memo->type > 2) &&
|
|
|
|
(memo->month == shown->mon) &&
|
|
|
|
(memo->year == shown->year)));
|
2009-08-03 16:30:08 +00:00
|
|
|
k = 0;
|
|
|
|
while (1)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2009-08-03 16:30:08 +00:00
|
|
|
if (rb->read(fp, temp_memo1, 1) != 1)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->day = 0;
|
|
|
|
memo->month = 0;
|
|
|
|
memo->file_pointer_start = 0;
|
|
|
|
memo->file_pointer_end = 0;
|
|
|
|
memo->year = 0;
|
|
|
|
memo->type = 0;
|
|
|
|
memo->wday = 0;
|
|
|
|
memo->message[0] = 0;
|
2003-07-24 10:03:33 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
}
|
2009-08-03 16:30:08 +00:00
|
|
|
if (load_to_memory)
|
|
|
|
{
|
|
|
|
if (temp_memo1[0] == '\n')
|
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
if (memo->type > 0)
|
|
|
|
day_has_memo[memo->day] = true;
|
2009-08-03 16:30:08 +00:00
|
|
|
else
|
2009-10-20 15:13:57 +00:00
|
|
|
wday_has_memo[memo->wday] = true;
|
|
|
|
memo->file_pointer_end = rb->lseek(fp, 0, SEEK_CUR);
|
|
|
|
memos_in_memory++;
|
2009-08-03 16:30:08 +00:00
|
|
|
}
|
|
|
|
else if ( (temp_memo1[0] != '\r') &&
|
|
|
|
(temp_memo1[0] != '\t') &&
|
|
|
|
k < MAX_CHAR_MEMO_LEN-1 )
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->message[k++] = temp_memo1[0];
|
2009-08-03 16:30:08 +00:00
|
|
|
}
|
|
|
|
if (temp_memo1[0] == '\n')
|
|
|
|
break;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-05 13:37:34 +00:00
|
|
|
rb->close(fp);
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool save_memo(int changed, bool new_mod, struct shown *shown)
|
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
int fp, fq;
|
2009-08-05 13:37:34 +00:00
|
|
|
/* use O_RDWR|O_CREAT so that file is created if it doesn't exist. */
|
2010-05-06 17:35:13 +00:00
|
|
|
fp = rb->open(MEMO_FILE, O_RDWR|O_CREAT, 0666);
|
2010-05-06 17:35:04 +00:00
|
|
|
fq = rb->creat(TEMP_FILE, 0666);
|
2009-08-03 16:30:08 +00:00
|
|
|
if ( (fq > -1) && (fp > -1) )
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
|
|
|
int i;
|
2008-10-24 08:40:48 +00:00
|
|
|
char temp[MAX_CHAR_MEMO_LEN];
|
2009-10-20 15:13:57 +00:00
|
|
|
struct memo *memo = &memos[changed];
|
2003-07-24 10:03:33 +00:00
|
|
|
rb->lseek(fp, 0, SEEK_SET);
|
2009-10-20 15:13:57 +00:00
|
|
|
for (i = 0; i < memo->file_pointer_start; i++)
|
2003-08-08 01:50:51 +00:00
|
|
|
{
|
|
|
|
rb->read(fp, temp, 1);
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->write(fq, temp, 1);
|
2003-08-08 01:50:51 +00:00
|
|
|
}
|
|
|
|
if (new_mod)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2005-02-22 12:19:12 +00:00
|
|
|
rb->fdprintf(fq, "%02d%02d%04d%01d%01d%s\n",
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->day, memo->month, memo->year, memo->wday,
|
|
|
|
memo->type, memo->message);
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->lseek(fp, memo->file_pointer_end, SEEK_SET);
|
2008-10-24 08:40:48 +00:00
|
|
|
while(rb->read(fp, temp, 1) == 1)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->write(fq, temp, 1);
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
2003-08-08 01:50:51 +00:00
|
|
|
rb->close(fp);
|
2003-07-24 10:03:33 +00:00
|
|
|
rb->close(fq);
|
2009-08-29 15:38:08 +00:00
|
|
|
rb->remove(MEMO_FILE);
|
|
|
|
rb->rename(TEMP_FILE, MEMO_FILE);
|
2003-07-24 10:03:33 +00:00
|
|
|
load_memo(shown);
|
|
|
|
return true;
|
|
|
|
}
|
2009-08-03 16:30:08 +00:00
|
|
|
else if (fp > -1)
|
2003-07-24 10:03:33 +00:00
|
|
|
rb->close(fp);
|
2009-08-03 16:30:08 +00:00
|
|
|
else if (fq > -1)
|
2003-07-24 10:03:33 +00:00
|
|
|
rb->close(fq);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_memo(struct shown *shown, int type)
|
|
|
|
{
|
|
|
|
bool saved = false;
|
2009-10-20 15:13:57 +00:00
|
|
|
struct memo *memo = &memos[memos_in_memory];
|
2020-07-21 06:33:53 +00:00
|
|
|
if (rb->kbd_input(memo->message, MAX_CHAR_MEMO_LEN, NULL) == 0)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
if (memo->message[0])
|
2008-10-24 08:40:48 +00:00
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->file_pointer_start = 0;
|
|
|
|
memo->file_pointer_end = 0;
|
|
|
|
memo->day = shown->mday;
|
|
|
|
memo->month = shown->mon;
|
|
|
|
memo->wday = shown->wday;
|
|
|
|
memo->year = shown->year;
|
|
|
|
memo->type = type;
|
|
|
|
if (save_memo(memos_in_memory, true, shown))
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
|
|
|
saved = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->file_pointer_start = 0;
|
|
|
|
memo->file_pointer_end = 0;
|
|
|
|
memo->day = 0;
|
|
|
|
memo->month = 0;
|
|
|
|
memo->year = 0;
|
|
|
|
memo->type = 0;
|
|
|
|
memo->wday = 0;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
if (saved)
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->splash(HZ/2, "Event added");
|
2003-07-24 10:03:33 +00:00
|
|
|
else
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->splash(HZ/2, "Event not added");
|
2008-10-25 16:34:15 +00:00
|
|
|
}
|
|
|
|
|
2020-07-19 17:42:04 +00:00
|
|
|
static int edit_menu_cb(int action,
|
|
|
|
const struct menu_item_ex *this_item,
|
|
|
|
struct gui_synclist *this_list)
|
2008-10-25 16:34:15 +00:00
|
|
|
{
|
2020-07-19 17:42:04 +00:00
|
|
|
(void)this_list;
|
2009-06-26 17:59:33 +00:00
|
|
|
int i = (intptr_t)this_item;
|
|
|
|
if (action == ACTION_REQUEST_MENUITEM
|
|
|
|
&& memos_in_shown_memory <= 0 && (i==0 || i==1))
|
2008-10-25 16:34:15 +00:00
|
|
|
return ACTION_EXIT_MENUITEM;
|
|
|
|
return action;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool edit_memo(int change, struct shown *shown)
|
|
|
|
{
|
|
|
|
bool exit = false;
|
2008-10-25 16:34:15 +00:00
|
|
|
int selected = 0;
|
|
|
|
|
2009-11-04 13:03:42 +00:00
|
|
|
static const struct opt_items modes[7] = {
|
|
|
|
{ "Mon", -1 },
|
|
|
|
{ "Tue", -1 },
|
|
|
|
{ "Wed", -1 },
|
|
|
|
{ "Thu", -1 },
|
|
|
|
{ "Fri", -1 },
|
|
|
|
{ "Sat", -1 },
|
|
|
|
{ "Sun", -1 },
|
|
|
|
};
|
|
|
|
|
2009-06-26 17:59:33 +00:00
|
|
|
MENUITEM_STRINGLIST(edit_menu, "Edit menu", edit_menu_cb,
|
|
|
|
"Remove", "Edit",
|
|
|
|
"New Weekly", "New Monthly",
|
2009-08-05 14:29:29 +00:00
|
|
|
"New Yearly", "New One off",
|
2009-11-04 13:03:42 +00:00
|
|
|
"First Day of Week",
|
2009-08-05 14:29:29 +00:00
|
|
|
"Playback Control");
|
2008-10-25 16:34:15 +00:00
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
while (!exit)
|
|
|
|
{
|
2008-10-25 16:34:15 +00:00
|
|
|
switch (rb->do_menu(&edit_menu, &selected, NULL, false))
|
2004-07-27 06:19:01 +00:00
|
|
|
{
|
2008-10-25 16:34:15 +00:00
|
|
|
case 0: /* remove */
|
2009-10-20 15:13:57 +00:00
|
|
|
save_memo(change, false, shown);
|
2008-10-25 16:34:15 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
case 1: /* edit */
|
2009-10-20 15:13:57 +00:00
|
|
|
if(rb->kbd_input(memos[change].message,
|
2020-07-21 06:33:53 +00:00
|
|
|
MAX_CHAR_MEMO_LEN, NULL) == 0)
|
2009-10-20 15:13:57 +00:00
|
|
|
save_memo(change, true, shown);
|
2003-07-24 10:03:33 +00:00
|
|
|
return false;
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case 2: /* weekly */
|
2009-10-20 15:13:57 +00:00
|
|
|
add_memo(shown, 0);
|
2003-11-20 00:47:16 +00:00
|
|
|
return false;
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case 3: /* monthly */
|
2009-10-20 15:13:57 +00:00
|
|
|
add_memo(shown, 1);
|
2003-11-20 00:47:16 +00:00
|
|
|
return false;
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case 4: /* yearly */
|
2009-10-20 15:13:57 +00:00
|
|
|
add_memo(shown, 2);
|
2003-11-20 00:47:16 +00:00
|
|
|
return false;
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case 5: /* one off */
|
2009-10-20 15:13:57 +00:00
|
|
|
add_memo(shown, 3);
|
2003-11-20 00:47:16 +00:00
|
|
|
return false;
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2009-11-04 13:03:42 +00:00
|
|
|
case 6: /* weekday */
|
2009-12-14 21:51:42 +00:00
|
|
|
rb->set_option("First Day of Week", &info.first_wday,
|
2009-11-04 13:03:42 +00:00
|
|
|
INT, modes, 7, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: /* playback control */
|
2009-08-05 14:29:29 +00:00
|
|
|
playback_control(NULL);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case GO_TO_PREVIOUS:
|
|
|
|
return false;
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case MENU_ATTACHED_USB:
|
|
|
|
been_in_usb_mode = true;
|
2004-07-27 06:19:01 +00:00
|
|
|
break;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-20 16:47:44 +00:00
|
|
|
static const char* get_event_text(int selected, void *data,
|
2008-10-25 16:34:15 +00:00
|
|
|
char *buffer, size_t buffer_len)
|
|
|
|
{
|
|
|
|
struct shown *shown = (struct shown *) data;
|
2009-10-20 15:13:57 +00:00
|
|
|
struct memo *memo;
|
2008-10-25 16:34:15 +00:00
|
|
|
if (selected < 0 || memos_in_shown_memory <= selected)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-10-20 15:13:57 +00:00
|
|
|
memo = &memos[pointer_array[selected]];
|
|
|
|
if (memo->type == 2)
|
2008-10-25 16:34:15 +00:00
|
|
|
rb->snprintf(buffer, buffer_len, "%s (%d yrs)",
|
2009-10-20 15:13:57 +00:00
|
|
|
memo->message, shown->year - memo->year);
|
2008-10-25 16:34:15 +00:00
|
|
|
else
|
2009-10-20 15:13:57 +00:00
|
|
|
rb->snprintf(buffer, buffer_len, "%s", memo->message);
|
2008-10-25 16:34:15 +00:00
|
|
|
return buffer;
|
|
|
|
}
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
static bool view_events(int selected, struct shown *shown)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2008-10-25 16:34:15 +00:00
|
|
|
struct gui_synclist gui_memos;
|
|
|
|
bool exit=false;
|
|
|
|
int button;
|
|
|
|
|
|
|
|
rb->gui_synclist_init(&gui_memos, &get_event_text, shown, false, 1, NULL);
|
2015-12-27 17:14:41 +00:00
|
|
|
rb->gui_synclist_set_title(&gui_memos, "Events (" CALENDAR_EVENT_MENU_NAME " : menu)", NOICON);
|
2008-10-25 16:34:15 +00:00
|
|
|
rb->gui_synclist_set_nb_items(&gui_memos, memos_in_shown_memory);
|
|
|
|
rb->gui_synclist_select_item(&gui_memos, selected);
|
|
|
|
rb->gui_synclist_draw(&gui_memos);
|
2009-08-03 16:30:08 +00:00
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
while (!exit)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK);
|
|
|
|
rb->gui_synclist_do_button(&gui_memos, &button, LIST_WRAP_UNLESS_HELD);
|
2008-10-25 16:34:15 +00:00
|
|
|
|
|
|
|
switch (button)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2008-10-25 16:34:15 +00:00
|
|
|
case ACTION_STD_OK:
|
|
|
|
selected = rb->gui_synclist_get_sel_pos(&gui_memos);
|
2009-10-20 15:13:57 +00:00
|
|
|
return edit_memo(pointer_array[selected], shown);
|
2008-10-25 16:34:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACTION_STD_CANCEL:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
been_in_usb_mode = true;
|
|
|
|
break;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-25 16:34:15 +00:00
|
|
|
|
|
|
|
return false;
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void update_memos_shown(struct shown *shown)
|
|
|
|
{
|
2003-07-24 12:22:10 +00:00
|
|
|
int i;
|
2009-10-20 15:13:57 +00:00
|
|
|
struct memo *memo;
|
2003-07-24 10:03:33 +00:00
|
|
|
memos_in_shown_memory = 0;
|
|
|
|
for (i = 0; i < memos_in_memory; i++)
|
2009-10-20 15:13:57 +00:00
|
|
|
{
|
|
|
|
memo = &memos[i];
|
|
|
|
if (((memo->type >= 1) && (memo->day == shown->mday)) ||
|
|
|
|
((memo->type < 1) && (memo->wday == shown->wday)))
|
2003-07-24 10:03:33 +00:00
|
|
|
pointer_array[memos_in_shown_memory++] = i;
|
2009-10-20 15:13:57 +00:00
|
|
|
}
|
2003-07-24 10:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool any_events(struct shown *shown, bool force)
|
|
|
|
{
|
2003-07-24 12:22:10 +00:00
|
|
|
update_memos_shown(shown);
|
2008-10-25 16:34:15 +00:00
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
if (memos_in_shown_memory > 0)
|
2008-10-25 16:34:15 +00:00
|
|
|
return view_events(0, shown);
|
2003-07-24 10:03:33 +00:00
|
|
|
else if (force)
|
2008-10-25 16:34:15 +00:00
|
|
|
return edit_memo(0, shown);
|
2003-07-24 10:03:33 +00:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void next_month(struct shown *shown, int step)
|
|
|
|
{
|
|
|
|
shown->mon++;
|
|
|
|
if (shown->mon > 12)
|
|
|
|
{
|
2009-10-20 15:13:57 +00:00
|
|
|
shown->mon = 1;
|
2003-07-24 10:03:33 +00:00
|
|
|
shown->year++;
|
|
|
|
leap_year = is_leap_year(shown->year);
|
|
|
|
}
|
2008-10-24 08:40:48 +00:00
|
|
|
if (step > 0)
|
2003-07-24 10:03:33 +00:00
|
|
|
shown->mday = shown->mday - days_in_month[leap_year][shown->mon-1];
|
|
|
|
else if (shown->mday > days_in_month[leap_year][shown->mon])
|
|
|
|
shown->mday = days_in_month[leap_year][shown->mon];
|
|
|
|
shown->firstday = shown->lastday;
|
|
|
|
load_memo(shown);
|
|
|
|
draw_calendar(shown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prev_month(struct shown *shown, int step)
|
|
|
|
{
|
|
|
|
shown->mon--;
|
|
|
|
if (shown->mon < 1)
|
|
|
|
{
|
|
|
|
shown->mon = 12;
|
|
|
|
shown->year--;
|
|
|
|
leap_year = is_leap_year(shown->year);
|
|
|
|
}
|
|
|
|
if (step > 0)
|
|
|
|
shown->mday = shown->mday + days_in_month[leap_year][shown->mon];
|
|
|
|
else if (shown->mday > days_in_month[leap_year][shown->mon])
|
|
|
|
shown->mday = days_in_month[leap_year][shown->mon];
|
|
|
|
shown->firstday += 7 - (days_in_month[leap_year][shown->mon] % 7);
|
2009-10-20 15:13:57 +00:00
|
|
|
if (shown->firstday >= 7)
|
|
|
|
shown->firstday -= 7;
|
2003-07-24 10:03:33 +00:00
|
|
|
load_memo(shown);
|
|
|
|
draw_calendar(shown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void next_day(struct shown *shown, int step)
|
|
|
|
{
|
|
|
|
shown->mday += step;
|
|
|
|
if (shown->mday > days_in_month[leap_year][shown->mon])
|
|
|
|
next_month(shown, step);
|
|
|
|
else
|
|
|
|
draw_calendar(shown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prev_day(struct shown *shown, int step)
|
|
|
|
{
|
|
|
|
shown->mday -= step;
|
|
|
|
if (shown->mday < 1)
|
|
|
|
prev_month(shown, step);
|
|
|
|
else
|
|
|
|
draw_calendar(shown);
|
|
|
|
}
|
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2003-07-24 12:22:10 +00:00
|
|
|
struct shown shown;
|
|
|
|
bool exit = false;
|
2004-07-27 06:19:01 +00:00
|
|
|
int button;
|
2009-08-03 16:30:08 +00:00
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
(void)(parameter);
|
2006-01-15 18:20:18 +00:00
|
|
|
|
2009-12-14 21:51:42 +00:00
|
|
|
configfile_load(CFG_FILE, config, ARRAYLEN(config), 0);
|
|
|
|
rb->memcpy(&old_info, &info, sizeof(struct info));
|
2009-11-04 13:03:42 +00:00
|
|
|
|
2009-10-03 09:33:42 +00:00
|
|
|
calendar_init(&shown);
|
2003-07-24 10:03:33 +00:00
|
|
|
load_memo(&shown);
|
|
|
|
any_events(&shown, false);
|
|
|
|
draw_calendar(&shown);
|
2009-11-04 13:03:42 +00:00
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
while (!exit)
|
|
|
|
{
|
2004-07-27 06:19:01 +00:00
|
|
|
button = rb->button_get(true);
|
|
|
|
switch (button)
|
2003-07-24 10:03:33 +00:00
|
|
|
{
|
2008-10-25 16:34:15 +00:00
|
|
|
case CALENDAR_QUIT:
|
2009-08-29 15:38:08 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case CALENDAR_NEXT_MONTH:
|
|
|
|
case CALENDAR_NEXT_MONTH | BUTTON_REPEAT:
|
2003-07-24 10:03:33 +00:00
|
|
|
next_month(&shown, 0);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case CALENDAR_PREV_MONTH:
|
|
|
|
case CALENDAR_PREV_MONTH | BUTTON_REPEAT:
|
2003-07-24 10:03:33 +00:00
|
|
|
prev_month(&shown, 0);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case CALENDAR_NEXT_WEEK:
|
|
|
|
case CALENDAR_NEXT_WEEK | BUTTON_REPEAT:
|
2003-07-24 10:03:33 +00:00
|
|
|
next_day(&shown, 7);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case CALENDAR_PREV_WEEK:
|
|
|
|
case CALENDAR_PREV_WEEK | BUTTON_REPEAT:
|
2003-07-24 10:03:33 +00:00
|
|
|
prev_day(&shown, 7);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case CALENDAR_PREV_DAY:
|
|
|
|
case CALENDAR_PREV_DAY | BUTTON_REPEAT:
|
2003-07-24 10:03:33 +00:00
|
|
|
prev_day(&shown, 1);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case CALENDAR_NEXT_DAY:
|
|
|
|
case CALENDAR_NEXT_DAY | BUTTON_REPEAT:
|
2003-07-24 10:03:33 +00:00
|
|
|
next_day(&shown, 1);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 16:34:15 +00:00
|
|
|
case CALENDAR_SELECT:
|
2004-10-17 00:54:09 +00:00
|
|
|
any_events(&shown, true);
|
2003-07-24 10:03:33 +00:00
|
|
|
draw_calendar(&shown);
|
|
|
|
break;
|
|
|
|
|
2004-07-27 06:19:01 +00:00
|
|
|
default:
|
|
|
|
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
been_in_usb_mode = true;
|
2003-07-24 10:03:33 +00:00
|
|
|
draw_calendar(&shown);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-11-04 13:03:42 +00:00
|
|
|
|
2003-07-24 10:03:33 +00:00
|
|
|
|
2009-12-14 21:51:42 +00:00
|
|
|
#if (CONFIG_RTC == 0)
|
|
|
|
info.last_mon = shown.mon;
|
|
|
|
info.last_year = shown.year;
|
2003-07-24 10:03:33 +00:00
|
|
|
#endif
|
2009-12-14 21:51:42 +00:00
|
|
|
if (rb->memcmp(&old_info, &info, sizeof(struct info)))
|
|
|
|
configfile_save(CFG_FILE, config, ARRAYLEN(config), 0);
|
|
|
|
return been_in_usb_mode?PLUGIN_USB_CONNECTED:PLUGIN_OK;
|
|
|
|
}
|