Skip to content

bilgump/Simulator---Calendar-Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Spreadtrum Calculator & Calendar CLI Simulator

(UNISOC T107 ― PC-based test-bed)

This tiny command-line program lets you exercise the same arithmetic and memory logic that lives in your feature-phone firmware without the RTOS GUI, touch panel or timers. Build it once on Windows (MinGW/VS Code, PowerShell shown below) or Linux/macOS, then run it in any terminal and drive it with your keyboard.

0 . Prerequisites & When you need a tool-chain

Use-case: Just run the simulator (calc_cli.exe or 'cal_cli.exe' in build/ or the pre-made calc_cli.exe) Do you need to install GCC / CMake?: No – copy the .exe anywhere and double-click or run it from cmd / PowerShell. Details: The binary is fully self-contained; Windows 10+ already ships the required C runtime (ucrtbase.dll).

Use-case: Re-build from source (change code, re-compile) Do you need to install GCC / CMake?: Yes – install: · MinGW-w64 – GCC 11 or newer· CMake ≥ 3.20 (optional if you prefer the one-line gcc … command)and add both mingw64\bin and CMake to your PATH. Details: After installing you can open a new terminal and run gcc --version or cmake --version to verify the PATH is correct.

Tip: the portable “x86_64-posix-seh” MinGW zip works fine, no registry changes needed.
Linux/macOS users: a system GCC/Clang plus make or ninja is enough.


1 . Build from source

1.1 Cross-platform (CMake 3.20+) (I Recommend this)

cd #to get into the folder which the project build folder is in

clean + configure (PowerShell)

Remove-Item -Recurse -Force .\build # optional: full clean cmake -B build -G "MinGW Makefiles" # or -G "Ninja" if installed cmake --build build # ⇒ build\calc_cli.exe build\cal_cli.exe

run

.\build\calc_cli.exe # calculator .\build\cal_cli.exe # calendar

1.2 One-liner (Windows & MinGW only)

C:\path\to\phone_sim\src\sim_src> gcc -std=c99 -Wall -Wextra driver_calendar.c calendar_core.c schedule_core.c shim.c -lm -o cal_cli.exe


2 . Running the simulator

Action -> Command / key Launch -> run calc_cli.exe (or cal_cli.exe) in any terminal Quit -> press q Resize -> just stretch your console; output fits in a single line

The program prints a static key-help banner once, then continuously rewrites a single status line (carriage return - style) so your scroll-back buffer stays clean.


3 . Key Maps and Functions

3.1 Calculator Key Map

Phone key PC keyboard substitute Notes
+ w
- s
× (multiply) a (*)
÷ (divide) d (/)
. (decimal point) . Duplicate dots are ignored
± (sign toggle) # Toggles minus sign unless the value is zero
Digits 0-9 same keys Leading zero rules mimic the phone firmware
Backspace / DEL Backspace Deletes one character in current operand
Long Backspace Ctrl + Backspace Full “CLR” — resets operands, operator and errors
CLR / MC x Also clears the memory register
MR m Recalls register into current operand
M+ p Adds current operand to memory
M- n Subtracts current operand from memory
= Enter / Return Executes calculation
Quit program q

A lit [M] indicator at the left of the status line means the memory register holds a value (set by M+, M- or MR).

3.2 Calendar Key Map

Category PC key Function
Day a / d previous / next day
Week jump w / s previous / next week
Month jump j / l previous / next month
Year jump k / ; previous / next year
Today t snap cursor to today
View v toggle Month ⇄ Week view
Agenda e add event to cursor date
o list events on cursor date
c clear all events on cursor date
Help h show banner
Quit q exit program

3.3 View legends:

Month grid — cursor [ ], today < > Week list — cursor [*], today

3.4 Agenda notes

-> In-memory only: exits erase events (no file persistence). -> Time format when adding: HH:MM Title  e.g. 07:30 Flight. -> Up to 64 events total across all days.

3.5 General Notes:

-> start the calendar with given input in main() inside driver_calendar.c


4 . Display format rules (same as firmware)

Calculator -> ≤ 13 significant digits; scientific when |value| ≥ 1 e13 or ≤ 1 e-11. -> Overflow (>|9.9 e100|) or ÷0 set error state until next digit entry.

Calendar -> Gregorian only; week starts Sunday by default. -> Date arithmetic clamps month-end correctly and honours leap years. -> Week view always shows Sun→Sat row starting from the Sunday of the week that contains the cursor date.


5 . Troubleshooting

Symptom Fix
ANSI escape codes shown as [H etc. Enable Virtual Terminal on old cmd.exe or use Windows Terminal / PowerShell / VS Code terminal.
Ctrl + Backspace doesn’t clear Your shell remaps it—use Del (ASCII 127) or x.
“gcc not found” Ensure mingw64\bin is in PATH or install build-essential (Linux).
Characters mis-aligned Use a monospaced font and UTF-8 or CP-1252 codepage.

6 . Implementation notes (why some code looks different)

  • GUI / RTOS calls removed – all MMK_…, GUI_…, SCI_TRACE and timer APIs from the phone firmware were replaced by plain C functions or no-ops, because they make sense only on the actual handset.
  • Logging – the original code used Spreadtrum trace macros; inside the simulator every diagnostic message is routed to standard output with printf().

If you copy new helper functions from the firmware, replace those macros or wrap them in printf before compiling.

  • Memory indicator – on the phone a little “[M]” icon is drawn by the GUI; the CLI prints it as text at the beginning of the status line.
  • Long-press keys – touch-panel “press & hold” events are approximated with Ctrl + Backspace (CLR) and DEL (when the terminal sends ASCII 127).

Same public symbols – MMIAPICALEND_OpenMainWin, CalendarKeyHandle, calc_calculate, CALE_SOLAR_DATE_T, etc.—so the untouched Spreadtrum sources still link if you compile them alongside the simulator.

Agenda layer – mirrors firmware schedule API (add / list / clear), but is intentionally RAM-only; persistence & alarm ringing can be added later without touching existing front-end code.

Festival / lunar hook – call: calendar_set_festival_cb(my_callback) to decorate week view with holiday names; not used by default.

About

A simulator for a phone CPU, mimicing it's calculator and calendar operations in Windows CMD with GCC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors