-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61ee4e3
commit 3875a0a
Showing
18 changed files
with
345 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
# | ||
# d3m0n C main software | ||
|
||
## Startup steps | ||
for each .d3m0n file in `/usr/share/d3m0n` and subfolder, unzip it into /usr/share/d3m0n/temp/RANDOM_TOKEN | ||
|
||
[example .d3m0n app](https://github.com/d3m0n-project/d3m0n_os/tree/main/rootfs/usr/share/d3m0n/apps/test_app/source) | ||
|
||
## App handler | ||
Phone loads apps from temp directory created when startup, | ||
|
||
then reads manifest file located at `/usr/share/d3m0n/temp/APP_TOKEN/app` | ||
- Gets app name, description, category, icon (format "key: value") | ||
then reads main layout file (.layout) in `/usr/share/d3m0n/temp/APP_TOKEN/layouts/main.layout` (example [here](https://github.com/d3m0n-project/d3m0n_os/blob/main/rootfs/usr/share/d3m0n/apps/test_app/source/layouts/main.layout)) | ||
|
||
then execute code (.src) in `/usr/share/d3m0n/temp/APP_TOKEN/src/main.src` (example [here](https://github.com/d3m0n-project/d3m0n_os/blob/main/rootfs/usr/share/d3m0n/apps/test_app/source/src/main.src)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
char *getSetting(char *name, char *path) | ||
{ | ||
FILE *fptr = fopen(path, "r"); | ||
|
||
if(fptr == NULL) | ||
{ | ||
printf("[x] Error reading SettingsFile: doesn't exist\n"); | ||
return "file not found"; | ||
} | ||
|
||
|
||
// Store the content of the file | ||
char line[500]; | ||
char *output = "not found"; | ||
|
||
while (fgets(line, 500, fptr)) | ||
{ | ||
char *token = strtok(line, ": "); | ||
|
||
// printf("token: '%s', '%s'\n", token, name); | ||
|
||
if(strcmp(token, name) == 0) | ||
{ | ||
token = strtok(NULL, ": "); | ||
// printf("token: '%s'\n", token); | ||
|
||
output = strdup(token); | ||
break; | ||
} | ||
|
||
} | ||
|
||
// Close the file | ||
fclose(fptr); | ||
|
||
return(output); | ||
} | ||
|
||
void writeSetting(char *name, char *value, char *path) | ||
{ | ||
FILE *fptr; | ||
|
||
fptr = fopen(path,"w"); | ||
|
||
if(fptr == NULL) | ||
{ | ||
printf("[x] Error writting SettingsFile: doesn't exist\n"); | ||
exit(1); | ||
} | ||
|
||
fprintf(fptr,"name2: custom_value"); | ||
fclose(fptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// functions.h | ||
#ifndef SETTINGSFILEHANDLER_H | ||
#define SETTINGSFILEHANDLER_H | ||
|
||
char* getSetting(char *name, char *path); | ||
void writeSetting(char *name, char *value, char *path); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
using namespace std; | ||
|
||
class appManager { | ||
void loadApps() | ||
{ | ||
|
||
Application newApp; | ||
newApp.name = ""; | ||
newApp.icon = ""; | ||
newApp.path = ""; | ||
newApp.id = 0; | ||
} | ||
|
||
void runApp(int id) | ||
{} | ||
|
||
void closeApp(int id) | ||
{} | ||
|
||
struct Application { | ||
char *name; | ||
char *icon; | ||
int id; | ||
char *path; | ||
|
||
}; | ||
}; |
11 changes: 11 additions & 0 deletions
11
rootfs/usr/share/d3m0n/src/application/applicationHandler.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class applicationHandler { | ||
void loadApp(char* appPath) | ||
{ | ||
// loads app by unziping appPath file into /usr/share/d3m0n/temp/RANDOM_TOKEN | ||
|
||
} | ||
void runApp(Application app) | ||
{ | ||
// runs app from Application struct. Gets path, runs /layout/main.layout then /src/main.src | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
rootfs/usr/share/d3m0n/src/application/applicationHandler.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
class applicationHandler { | ||
public: | ||
void loadApp(char* appPath); | ||
void runApp(Application app); | ||
} | ||
|
||
struct Application | ||
{ | ||
char* name; | ||
char* package; | ||
char* icon; | ||
char* perms; | ||
char* start_path; | ||
char* category; | ||
}; |
5 changes: 5 additions & 0 deletions
5
rootfs/usr/share/d3m0n/src/application/layout/layoutHandler.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <> | ||
|
||
class layout { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
rootfs/usr/share/d3m0n/src/application/layout/layoutHandler.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef LAYOUT_H | ||
#define LAYOUT_H | ||
|
||
class layoutHandler { | ||
public: | ||
void init(); | ||
int width = 240; | ||
int height = 320; | ||
short backColor = 0x0; | ||
}; | ||
|
||
#endif |
Empty file.
3 changes: 3 additions & 0 deletions
3
rootfs/usr/share/d3m0n/src/application/source/sourceHandler.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class sourceHandler { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@echo off | ||
|
||
set path=%path%;C:\Users\celcm\MinGW\lib\gcc\x86_64-w64-mingw32\13.2.0 | ||
|
||
set homepath=%cd% | ||
|
||
cd C:\Users\celcm\MinGW\bin\ | ||
|
||
call gcc "%homepath%\*.c" -o d3m0n.exe | ||
|
||
pause | ||
|
||
mv d3m0n.exe "%homepath%\d3m0n.exe" | ||
|
||
cd "%homepath%" | ||
|
||
call d3m0n.exe | ||
|
||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
clear | ||
|
||
gcc *.cpp *.c -Ilibs/ili9340/ -Wall -std=c99 -o d3m0n | grep "error" | ||
|
||
chmod 777 ./d3m0n | ||
|
||
./d3m0n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include "SettingsFileHandler.h" | ||
#include "display.hpp" | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
printf("d3m0n OS\n"); | ||
printf(getSetting("name2", "./text.txt")); | ||
|
||
//writeSetting("name1", "value2", "text.txt"); | ||
|
||
|
||
|
||
// init display | ||
//display display1; | ||
//display1.init(); | ||
|
||
// load apps in memory | ||
|
||
// loads apps launcher | ||
// load topbar | ||
// load background | ||
|
||
// load splashscreen | ||
// load apps in grid | ||
|
||
// hide splashscreen | ||
|
||
printf("\n"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
#include <time.h> | ||
#include <iostream> | ||
#include <sys/time.h> | ||
|
||
#include "display.hpp" | ||
#include "ili9340.h" | ||
using namespace std; | ||
|
||
|
||
void display::init() | ||
{ | ||
cout << "display init\n"; | ||
lcdReset(); | ||
lcdSetup(); | ||
lcdInit(display::width, display::height, 0, 0); | ||
|
||
lcdFillScreen(backColor); | ||
} | ||
// lcdWriteCommandByte(byte c); | ||
// lcdWriteDataByte(byte c); | ||
// lcdWriteDataWord(ushort w); | ||
// lcdWriteColor(ushort color, IntPtr size); | ||
// lcdInit(int width, int height, int offsetx, int offsety); | ||
// lcdReset(); | ||
// lcdSetup(); | ||
// lcdDrawPixel(ushort x, ushort y, ushort color); | ||
// lcdDrawFillRect(ushort x1, ushort y1, ushort x2, ushort y2, ushort color); | ||
// lcdDisplayOff(); | ||
// lcdDisplayOn(); | ||
// lcdInversionOn(); | ||
// lcdFillScreen(ushort color); | ||
// lcdDrawLine(ushort x1, ushort y1, ushort x2, ushort y2, ushort color); | ||
// lcdDrawRect(ushort x1, ushort y1, ushort x2, ushort y2, ushort color); | ||
// lcdDrawCircle(ushort x0, ushort y0, ushort r, ushort color); | ||
// lcdDrawFillCircle(ushort x0, ushort y0, ushort r, ushort color); | ||
// lcdDrawRoundRect(ushort x1, ushort y1, ushort x2, ushort y2, ushort r, ushort color); | ||
// lcdDrawArrow(ushort x0, ushort y0, ushort x1, ushort y1, ushort w, ushort color); | ||
// lcdDrawFillArrow(ushort x0, ushort y0, ushort x1, ushort y1, ushort w, ushort color); | ||
// lcdDrawSJISChar(IntPtr fx, ushort x, ushort y, ushort sjis, ushort color); // [DllImport("./lib.so", CallingConvention = CallingConvention.Cdecl)] | ||
// xxxxlcdDrawUTF8Char(FontxFile[] fx, ushort x, ushort y, string utf8, ushort color); // [DllImport("./lib.so", CallingConvention = CallingConvention.Cdecl)] | ||
// xxxxlcdDrawUTF8String(FontxFile[] fx, ushort x, ushort y, string utfs, ushort color); | ||
// lcdSetFontDirection(ushort direction); | ||
// lcdSetFontFill(ushort color); | ||
// lcdUnsetFontFill(); | ||
// lcdSetFontUnderLine(ushort color); | ||
// lcdUnsetFontUnderLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// display.h | ||
#ifndef DISPLAY_H | ||
#define DISPLAY_H | ||
|
||
class display { | ||
public: | ||
void init(); | ||
int width = 240; | ||
int height = 320; | ||
short backColor = 0x0; | ||
// Declare other member functions and variables here | ||
}; | ||
|
||
#endif // DISPLAY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
char *getSetting(char *name, char *path) | ||
{ | ||
FILE *fptr = fopen(path, "r"); | ||
|
||
if(fptr == NULL) | ||
{ | ||
return "file not found"; | ||
} | ||
|
||
|
||
// Store the content of the file | ||
char line[500]; | ||
char *output="not found"; | ||
|
||
// Read the content and store it inside myString | ||
while (fgets(line, 500, fptr)) | ||
{ | ||
printf("%s", line); | ||
|
||
char *token = strtok(line, ": "); | ||
|
||
|
||
while (token != NULL) | ||
{ | ||
printf("%s\n", token); | ||
token = strtok(NULL, ": "); | ||
} | ||
} | ||
|
||
// Close the file | ||
fclose(fptr); | ||
|
||
return output; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@echo off | ||
|
||
REM use https://objects.githubusercontent.com/github-production-release-asset-2e65be/262681272/1bd1f438-ff5d-46f1-8832-f2f60058b780?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240201%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240201T151804Z&X-Amz-Expires=300&X-Amz-Signature=520f909821513cb0dfd27f1e5306fe3ea176a99bc5fa8a1d0dd8b4f00333d378&X-Amz-SignedHeaders=host&actor_id=71982379&key_id=0&repo_id=262681272&response-content-disposition=attachment%3B%20filename%3Dw64devkit-1.21.0.zip&response-content-type=application%2Foctet-stream | ||
|
||
set path=%path%;C:\Users\users\MinGW\lib\gcc\x86_64-w64-mingw32\13.2.0 | ||
|
||
set homepath=%cd% | ||
|
||
cd C:\Users\users\MinGW\bin\ | ||
|
||
call gcc "%homepath%\*.c" -o d3m0n.exe | ||
|
||
pause | ||
|
||
mv d3m0n.exe "%homepath%\d3m0n.exe" | ||
|
||
cd "%homepath%" | ||
|
||
call d3m0n.exe | ||
|
||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test: a | ||
name2: custom_value |