(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.
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 plusmakeorninjais enough.
cd #to get into the folder which the project build folder is in
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
.\build\calc_cli.exe # calculator .\build\cal_cli.exe # calendar
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
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.
| 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).
| 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 |
Month grid — cursor [ ], today < > Week list — cursor [*], today
-> 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.
-> start the calendar with given input in main() inside driver_calendar.c
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.
| 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. |
- GUI / RTOS calls removed – all
MMK_…,GUI_…,SCI_TRACEand 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.