diff --git a/README.md b/README.md index 8b26df6..2afb108 100644 --- a/README.md +++ b/README.md @@ -19,23 +19,58 @@ sudo reboot ``` **Wait for the system to restart** -## Clone SKU_RM0004 library +
+ +## Pre-Requisites +### Ubuntu +Install necessary dependencies to compile the project: +```bash +sudo apt install make gcc +``` +### Home Assistant +```bash +$ apk add make gcc musl-dev i2c-tools i2c-tools-dev linux-headers +``` + +## Building +### Clone SKU_RM0004 library ```bash git clone https://github.com/UCTRONICS/SKU_RM0004.git ``` -## Compile +### Compile ```bash cd SKU_RM0004 make ``` -## Run +### Run ``` ./display ``` +## Installing + +### Ubuntu +1. Create file `/etc/systemd/system/rpi-display.service` + ``` + [Unit] + After=network.target + [Service] + ExecStart=/home/user/git/SKU_RM0004/display + [Install] + WantedBy=default.target + ``` +1. Create folder (if it doesn't exist): + ``` + $ mkdir /etc/systemd/system/default.target.wants + ``` +1. Create soft link to service file: + ``` + $ ln -s /etc/systemd/system/rpi-display.service /etc/systemd/system/default.target.wants/default.target.wants + ``` +### Others ## Add automatic start script **Open the rc.local file** ```bash diff --git a/hardware/rpiInfo/rpiInfo.c b/hardware/rpiInfo/rpiInfo.c index c1cd831..8241906 100644 --- a/hardware/rpiInfo/rpiInfo.c +++ b/hardware/rpiInfo/rpiInfo.c @@ -98,7 +98,7 @@ void get_cpu_memory(float *Totalram,float *freeram) { *Totalram=value/1000.0/1000.0; } - else if(strcmp(famer,"MemFree:")==0) + else if(strcmp(famer,"MemAvailable:")==0) { *freeram=value/1000.0/1000.0; } @@ -135,11 +135,11 @@ uint8_t get_hard_disk_memory(uint16_t *diskMemSize, uint16_t *useMemSize) uint8_t diskMembuff[10] = {0}; uint8_t useMembuff[10] = {0}; FILE *fd = NULL; - fd=popen("df -l | grep /dev/sda | awk '{printf \"%s\", $(2)}'","r"); + fd=popen("df -l / | grep /dev/sda | awk '{printf \"%s\", $(2)}'","r"); fgets(diskMembuff,sizeof(diskMembuff),fd); fclose(fd); - fd=popen("df -l | grep /dev/sda | awk '{printf \"%s\", $(3)}'","r"); + fd=popen("df -l / | grep /dev/sda | awk '{printf \"%s\", $(3)}'","r"); fgets(useMembuff,sizeof(useMembuff),fd); fclose(fd); @@ -185,4 +185,4 @@ uint8_t get_cpu_message(void) syCpu = atoi(syCpubuff); return usCpu+syCpu; -} \ No newline at end of file +}