U6143_ssd1306
U6143_ssd1306 copied to clipboard
Major Update
Major refactor and cleanup of code to address multiple functional and stylistic issues.
- Update README.md
- Stylistic cleanup
- Rename functions to remove typos, provide better description of function
- Formatting
- Spelling errors
- Addressed many typos
- Reordered functions by order of call
- Removed unneeded includes
- Fixed
-Wall
compiler warnings - More robust error handling
- Fixed the way top was being called
- Added
/proc/stat
CPU calculation and enabled in favor oftop
(should be more accurate) - Added
df
disk free space calculation and enabled in favor ofstatfs()
(should be more portable) - Refactored the way numbers were being pushed to the display that should result in better formatting
- Fit decimals by width using significant figures
- Right-justify fields (against labels)
- Correctly display CPU temperature units of measurement (F displayed instead of C)
- Added additional logic to find default interface to query for IP address to display.
- Added
/contrib
directory, support scripts- script to tar up files
- systemd service script
Liking the result of this MR! Built it and am running it on my own Pis now and it's good stuff.
Suggest adding a mention of introducing the dependency on the wiringpi
package into the README, though for raspios users; that package doesn't seem to be a standard install.
edit: wtf, why does my clone's readme not show the dependencies section added. nvm me!
Suggest adding a mention of introducing the dependency on the
wiringpi
package into the README, though for raspios users; that package doesn't seem to be a standard install.
The wiringpi
dependency isn't introduced by my PR, it was a original dependency of the upstream. They've updated it since to remove it (but haven't incorporated any of the PRs). I've refitted that change, as it really simplifies the whole thing and resolves a number of lingering maintainability issues that are created by including it.
love this PR, can't understand why it hasn't been accepted by the maintainer
is there a way to get it to show host name in addition to IP?
love this PR, can't understand why it hasn't been accepted by the maintainer
Thanks! I wanted to get it working in my environment, and figured I'd share it back.
is there a way to get it to show host name in addition to IP?
Yes, though I don't intend to do so myself. The display code is all bitmapped, so you should be aware there's no fancy scrolling/marquee functions, and getting everything to fit and look good enough is more art than anything.
The labels and such are part of the background bitmap, so those may have to be refactored, depending on how you choose to implement it. I used an online tool to convert images to bitmap arrays to made the adjustments that were needed.
The display code isn't very complicated though, and it's pretty easy to understand, even for a C novice.
I have a working host name solution that looks fine and works great and is a simple logical change. I'm not a C expert though. Some minor changes might be needed to ensure best C practices.
Ok. I can't find a way to modify the PR. So add -
char *GetHostname(void)
{
FILE *fd;
char buffer[16] = {0};
char *host = malloc(16);
fd = fopen("/etc/hostname", "r");
if(fd == NULL)
{
fprintf(stderr, "ssd1306_i2c: Unable to open /etc/hostname.\n");
return 0;
}
fgets(buffer, sizeof(buffer), fd);
fclose(fd);
strcpy(host, buffer);
return host; // Host name
}
AND Modify this routine.
void LCD_DisplaySdMemoryDf(void)
{
char *mnt_dir = "/";
FILE *fp;
char buffer[32] = {0};
float usedsize = 0;
float totalsize = 0;
char used[4] = {0};
char total[4] = {0};
char host[16] = {0};
strcpy(host, GetHostname()); // Gets the hostname
fp = popen("df / | awk '{if (NR==2) {print $3 / 1048576\" \"$2 / 1048576}}'", "r");
if (fp == NULL)
{
fprintf(stderr, "ssd1306_i2c: Unable to stat %s filesystem.\n", mnt_dir);
return;
}
fgets(buffer, sizeof(buffer), fp);
pclose(fp);
// Parse buffer
sscanf(buffer, "%f %f", &usedsize, &totalsize);
sprintf_fix(total, 3, totalsize);
sprintf_fix(used, 3, usedsize);
/*
fprintf(stderr, "Disk Used: %f\tTotal: %f\n", usedsize, totalsize);
fprintf(stderr, "Disk Used: %s GiB\tTotal: %s GiB\n", used, total);
*/
OLED_ClearLint(0, 1); //clear IP address
OLED_ClearLint(2, 4);
OLED_ShowString(8, 0, host, 8); // Display Hostname
OLED_DrawPartBMP(0, 2, 128, 4, BMP, 2);
OLED_ShowString(90, 3, total, 8);
OLED_ShowString(55, 3, used, 8);
}
GitHub newbie here. How do I get the new code for this PR? I can see the comparison between old and new but cannot find a way to get the new code only. Want to try out the improvements.
GitHub newbie here. How do I get the new code for this PR? I can see the comparison between old and new but cannot find a way to get the new code only. Want to try out the improvements.
Probably easiest just to pull my fork of the repo. They don't seem to be responding to PRs, and worse, seen to be copying changes from the submitted PRs without attribution (which is pretty reprehensible).
So, I would install from git clone https://github.com/darkgrue/U6143_ssd1306.git and not from git clone https://github.com/UCTRONICS/U6143_ssd1306.git
as your README says, correct?
Yeah, that was written with the assumption that they'd be playing nice with the PRs, but they're not, so...
On Wed, Jan 26, 2022, 10:49 AM MarkusNiGit @.***> wrote:
So, I would install from https://github.com/darkgrue/U6143_ssd1306.git and not from git clone https://github.com/UCTRONICS/U6143_ssd1306.git
as your README says, correct?
— Reply to this email directly, view it on GitHub https://github.com/UCTRONICS/U6143_ssd1306/pull/16#issuecomment-1022388852, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOJ3HAV3VXDGGIZJWKLS73UYAQ2ZANCNFSM44PZ2TWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you modified the open/close state.Message ID: @.***>
Thank you very much for your help and for creating this improved program. Very cool for me to pick up working with c and pis.
You're quite welcome, have fun! =)
On Wed, Jan 26, 2022, 1:05 PM MarkusNiGit @.***> wrote:
Thank you very much for your help and for creating this improved program. Very cool for me to pick up working with c and pis.
From: darkgrue @.> Sent: Wednesday, January 26, 2022 10:26:40 AM To: UCTRONICS/U6143_ssd1306 @.> Cc: MarkusNiGit @.>; Comment @.> Subject: Re: [UCTRONICS/U6143_ssd1306] Major Update (#16)
Yeah, that was written with the assumption that they'd be playing nice with the PRs, but they're not, so...
On Wed, Jan 26, 2022, 10:49 AM MarkusNiGit @.***> wrote:
So, I would install from https://github.com/darkgrue/U6143_ssd1306.git and not from git clone https://github.com/UCTRONICS/U6143_ssd1306.git
as your README says, correct?
— Reply to this email directly, view it on GitHub < https://github.com/UCTRONICS/U6143_ssd1306/pull/16#issuecomment-1022388852 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAOJ3HAV3VXDGGIZJWKLS73UYAQ2ZANCNFSM44PZ2TWA
. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675
or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .
You are receiving this because you modified the open/close state.Message ID: @.***>
— Reply to this email directly, view it on GitHub< https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FUCTRONICS%2FU6143_ssd1306%2Fpull%2F16%23issuecomment-1022473462&data=04%7C01%7C%7C64cf3e2bac4d47ef17b208d9e0f96617%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637788184039020852%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=GFYiYneTlRbLwRZjqpi7mjhJ4OdMseVK1a8W%2B1W1VzA%3D&reserved=0>, or unsubscribe< https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAS4UEZVL7KMAEIQGWSFJVZTUYA4GBANCNFSM44PZ2TWA&data=04%7C01%7C%7C64cf3e2bac4d47ef17b208d9e0f96617%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637788184039020852%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=qXezAiaVVK3%2B4EpfqwOp3z18G%2FPxHegzA900IttYKPg%3D&reserved=0
. Triage notifications on the go with GitHub Mobile for iOS< https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C64cf3e2bac4d47ef17b208d9e0f96617%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637788184039020852%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=fLwRvLVy8AdyG256oBYUWVr%2F1Lf8xH1AJgUdTmyVUJQ%3D&reserved=0> or Android< https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7C64cf3e2bac4d47ef17b208d9e0f96617%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637788184039020852%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=1qTtV0Lp32uqnQeNLcaqQ29s0R6BOzQ82DYllpaFP7Q%3D&reserved=0 . You are receiving this because you commented.Message ID: @.***>
— Reply to this email directly, view it on GitHub https://github.com/UCTRONICS/U6143_ssd1306/pull/16#issuecomment-1022503220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOJ3HBIYNGL66LHTENBFZLUYBAWJANCNFSM44PZ2TWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you modified the open/close state.Message ID: @.***>