Giter Club home page Giter Club logo

there.oughta.be's Introduction

there.oughta.be

Projects featured on my blog at https://there.oughta.be

All projects are published under the GNU GPL 3.

Issues can be posted to the issue tracker (although not all projects will be actively supported). Discussions, ideas and presentations of your builds should be posted at r/thereoughtabe on reddit.

This repository is a collection of small projects that I share and present on https://there.oughta.be. If they end up here, this usually means that they are not particularly large and that I do not expect to actively maintain them. Nevertheless, if you want to submit a pull request or report an issue, I will see if I can do something, especially if it is a project that I am still using myself.

Buy Me A Coffee

there.oughta.be's People

Contributors

staacks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

there.oughta.be's Issues

App/Operational, but no LED Matrix Ouput

First of all, thank you for publishing this project.

I get no matrix output on my setup. System details below.
I have verified the Henner Zeller-library/demo example produces output.

I have verified pixel data is present within cp-stats-gl in variable 'canvas' up to the line:
canvas = matrix->SwapOnVSync(canvas);
I can set pixel data to a non-zero value and still no output.
I suspect gl is somehow not working, or vsync not occurring.

I have verified the gl versions according to tutorial, linked libraries, and actually run the raspberry pi example program:
/opt/vc/src/hello_pi/hello_triangle
Hello_Triangle produced graphics which leads me to believe gl is operable.

Question: Should a window/display appear when running triangle? or cp-stats-gl?
Triangle gives me the following status, which I am presuming is 'success' even without a display appearing.
Initialized EGL version: 1.4
GL Viewport size: 800x600

Details of system configuration.
Brand new Buster v10 (full)
Model : Raspberry Pi 3 Model B Rev 1.2

ldd cpu-stats-gl
linux-vdso.so.1 (0x7ecdd000)
/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0x76f22000)
libbrcmEGL.so => /opt/vc/lib/libbrcmEGL.so (0x76ed3000)
libbrcmGLESv2.so => /opt/vc/lib/libbrcmGLESv2.so (0x76eae000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76e97000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76e6d000)
libstdc++.so.6 => /lib/arm-linux-gnueabihf/libstdc++.so.6 (0x76d26000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76ca4000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x76c77000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76b29000)
libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x76b02000)
libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x76aec000)
libvcos.so => /opt/vc/lib/libvcos.so (0x76ad3000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76ac0000)
/lib/ld-linux-armhf.so.3 (0x76f37000)

ldd triangle
linux-vdso.so.1 (0x7ec77000)
/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0x76fa9000)
libbrcmEGL.so => /opt/vc/lib/libbrcmEGL.so (0x76f5a000)
libbrcmGLESv2.so => /opt/vc/lib/libbrcmGLESv2.so (0x76f35000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76de7000)
libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x76dc0000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76d3e000)
libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x76d28000)
libvcos.so => /opt/vc/lib/libvcos.so (0x76d0f000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76ce5000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76cd2000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76cbb000)
/lib/ld-linux-armhf.so.3 (0x76fbe000)

(All) STL and BLEND files are not to scale and "Sides" is not printable at all

The "sides" portion of the provided 3D print files are unprintable / unsliceable according to PrusaSlicer - and fail repair. I used Cura Slicer and printed from there - and printer will randomly print in the middle. I also tried using Blender to simply export to OBJ and STL manually and got same result (in PuraSlicer) - that the file is not printable and needs repair.

Also, all other files are out of scale and print very small despite trying multiple slicer programs. Is there a known scale for this to get it right? Perhaps percentage wise? Otherwise it prints about the size of a piece of Chex cereal squares. Perhaps the Blender export uploaded was not one used in project?

Thanks for this project! Got my LED side working, just cannot print.

Increase animation speed

Sorry to bother you again.
Is there an easy way to increase the animation speed? I have about 120fps with my Raspberry 3b+ and the
animation is smooth and looks pretty good.
But i like to have the animation speed kind of faster.
I have played with some values i found but the animation speed didn't change.
So how can i speed up the animation?

eglGetDisplay() returns "* failed to add service - already in use"

This is happening on a rpi4 running in headless mode.

I am able to successfully run the triangle_rpi4 example from https://github.com/matusnovak/rpi-opengl-without-x - where it can initialize EGL get a viewport and generate the output file.

I tried merging some of the display setup code from triangle_rpi4 (so that I'm calling eglGetDisplay() using a gbm_device structure, as he does in triangle_rpi4) - but, I still keep getting that error message from cpu-stats-gl.

Any ideas on what I'm missing or what would be causing that?

Temperature inversion

First of all, amazing job !!!! The cube is super impressive and everything is working super well.
Even if it is your project, it was super fun to copy cat it !

Not a big issue, but my temperatures are inverted on my version of the cube, I don't know why. when temperature are above 70, the cube is blue, when they are below 40, the cube is red....

I modify the first lines to fix that but I don't understand why i have such a behavior....

#define T1 80.0 // instead of 40 #define T2 60.0 #define T3 40.0 // instead of 80

LEDCube - panels do not work.

Hello.

I have a problem with my setup. I got no output with the examples of the hzeller/rpi-rgb-led-matrix library. I use a RPI 2b v1.1 and a Adafruit RGB Matrix Bonnet to drive a 64x64 LED Matrix of Aliexpress (https://a.aliexpress.com/_mLDLYhN)

For the hardware part:
I have soldered GPIO4 & GPIO18 for the quality setting
shorted out the middle pad to ‘8’ on the backside of the Adafruit RGB LED Bonnet

For the software part:

I have installed the LED-matrix library with quality mod for the bonnet.
I tried a couple of different flags. But i think, this should be the right:
sudo ./demo -D0 --led-rows=64 --led-cols=64

I also tried this with no success:

sudo ./demo -D0 --led-rows=64 --led-cols=64 --led-gpio-mapping=adafruit-hat

The RPI starts the DEMO, but the panel remains black. Absolutely nothing happens.

I also tried the convenience option. But its still the same. And i tried also the E to 16....

Please help :)

Best Regards!

Monochrome Display only

I am in the process of adapting the project to a cube with 5 64x64 panels.
I got the code (partially) running, my only problem is that my (adapted) code only display gray (i.e. no color depending on the CPU temperature). I determined it is not the panels, its the code. If I change the following two lines of code

        //gl_FragColor = vec4(mix(outcolor, gray, smoothstep(5.0, 10.0, age)), 1.0);  // original code, only gray scale
        gl_FragColor = vec4(mix(outcolor, outcolor, smoothstep(5.0, 10.0, age)), 1.0);

I get the colors working. I have not yet dived deeper in the code, but this is quite strange to me.
Any hint is welcome.

By the way: That is a great project, I will further develop my owen cube with 5 panels. I also 3D-printed the cube panel holders, but using my own design.

Rotate one panel

Hello

First, a great project. It looks awesome. Thank you for sharing the code. My cube runs fine.
I have one question. I need to rotate the image of the third panel in the chain by 90 degree clockwise.
I have tried to adapt the verticies, but i guess i'm not smart enough to understand this.
Even in school i didn't understand the vector stuff.
It would be nice if you could get me the values and an additional explanation for the new values. Maybe i can understand
it more.
I read your description and the samples here in the issues section, but i was not able to adapt to my situation.
Can you help?

Performance issue on RPI3

Hi

After having successfully run the program on a RPI4 without any issue except that RPI4 cannot run OpenGL in a headless mode, I have now switched to a RPI3 B+.

The problem of headless mode is now solved and everything is working without an HDMI output however I experienced some annoying flickering. I am a bit suprised as the RPI3 B+ is not that much less powerful than the RPI4 and you seem to run it successfully on a RPI2 !!!

I tried to play with runtime.gpio_slowdown, but the best parameter seems to be 4 like on the RPI4.

The only thing I did not try vs you is to reserve an entire CPU core to the task. First of all, I should reserve at least 2 as i have a quad core right ? Secondly I understand to do so we need to put isolcpus=3 in /boot/cmdline.txt but then how can we associate the task to this cpu ?

Furthermore, may I ask you what kind of option you use to run automatically the program at launch ?
You put sudo /home/pi/cpu-stats-gl & in /etc/rc.local ?

Thanks !

PS : I use rasbian lite with nothing else than the program

IDEA : Water effect

Not an issue but more a food for thoughts.

In south Korea, this is a building with a led wall showcasing some water waves in a cube : https://www.youtube.com/watch?v=eoLA0lUEaF8&ab_channel=SurferToday

image

I was wondering if we could set up the same kind of effect on the cube? Maybe leveraging a video of scene we create in Blender like this one ? https://www.youtube.com/watch?v=3EfgsciQ5rM&ab_channel=LawrenceJaeger

What do you think ? Even if the resolution won't be obvioulsy the same, it could be awesome !

No animation by using --led-daemon option

I'm still on testing of LED cube.
In case I run the led script like this, the animation works with 170Hz:

pi@pi-rgb:~/led $ sudo ./cpu
Initialized EGL version: 1.4
GL Viewport size: 192x64

If I start the led script as prozess, then there no animation:
pi@pi-rgb:~/led $ sudo ./cpu --led-daemon

The core 3 is isolated by using isolcpus=3 option in /boot/cmdline.txt. According to htop the led prozess runs on core 3 with 100%.

My goal to reduce the FPS from 170Hz to 60-120Hz and reduce the load of cpu.
And I would also like to run the animation on isolated core, to be able to use PI3 also for other purposes.

Please any advice?

P3 64x64 support

Fantastic project!
I have several P3 panels that I would like to use to make a similar cube but I cant get my head around Blender!
Is there any chance that someone can change the 3d prints for the P3 size?
For reference, the naked P3 panel is 192mm x 192mm

* failed to add service - already in use? - need help

Hi,
first thanks for this create project.
i compiled the code and get following massage when i try to run
it.
* failed to add service - already in use?
i tried to fix it search the web, but had no success.
i'm running a rpi4 B.
i have a other project running with rpi-rgb-led-matrix
so this works.

looking forward for help :)

Greetings Simon

Display on panels works for 6 seconds

Hello!

Thanks for this nice project.
I got my 64x64 panels and tried them with a Raspberry Pi3 A+ and the adafruit bonnet. It works fine with the examples coming with the last version of the master branch.
Then I changed the number of cores in your project (I have only 4 cores), compiled it, and started it with the python running on the PC (for remaining, code is psutil.sensors_temperatures()["coretemp"][0].current for my machine).

The display is fine on the 3 panels, but only for 6 seconds: after this time, display shut down, as the software continue to run on the raspberry. No error is displayed.

pi@raspberrypi:~/led-cube $ sudo ./cpu-stats-gl
Initialized EGL version: 1.4
GL Viewport size: 192x64

What could be wrong? Thanks!

Psutil

Hello all,

how to deal with this error in python script? It looks like Windows psutil doesn't support temperature measurements.
Python 3.9.0

temperature += psutil.sensors_temperatures()["k10temp"][0].current

AttributeError: module 'psutil' has no attribute 'sensors_temperatures'

Single panel

Hi, Great work!

I am trying to modify this code to run on a single panel. My opengl knowledge is not so great! Has anyone succeded in converting it into a single panel? That would be very helpful.

Or provide me with some idea on how to convert the code into a single panel.

Thanks

--led-limit-refresh option is missing

Hello guys,
to reduce the load and heating of PI 3 in LED cube I would like to limit the refresh rate by use --led-limit-refresh option.
But this option seems to be not implemented or missing.
Please advise how can the refresh-rate be reduced.
Thanks.

using "regular" led hat rather than adafruit?

I get a bit of flicker on the adafruit version so I am trying the https://www.electrodragon.com/product/rgb-matrix-panel-drive-board-raspberry-pi/

It works great with hzeller examples: ie
"sudo ./demo -D7 --led-parallel=3 --led-chain=1 --led-gpio-mapping=regular --led-cols=64 --led-rows=64"

But only uses one panel on ledcube. These are the settings that I am using.

//LED Matrix settings
RGBMatrix::Options defaults;
rgb_matrix::RuntimeOptions runtime;
defaults.hardware_mapping = "regular";
defaults.led_rgb_sequence = "RGB";
defaults.pwm_bits = 11;
defaults.pwm_lsb_nanoseconds = 75;
defaults.panel_type = "";
defaults.rows = 64;
defaults.cols = 64;
defaults.chain_length = 1;
defaults.parallel = 3;
runtime.drop_privileges = 0;
runtime.gpio_slowdown = 3;

(I tried default.cols at 192 as well)
It works ok in chain mode, just having trouble with parallel mode

Colors are in other order

I just rebuilt your project - great work. Absolutely fantastic!
Actually I tweak the sources a little bit because of different number of cores etc. in my system.

When I came to that part in cpu-stats-gl.cpp, I thought hot(red) means, that, if the temperature is above T3(=80 degrees), than it should become red, because that means hot.

//Temperature thresholds for cool (blue), medium (green/yellow) and hot (red)
#define T1 40.0 //Do not omit the decimal point. This will be used in the OpenGL shader which will otherwise interpret it as a float literal
#define T2 60.0
#define T3 80.0

But my cube becomes blue instead? It's red when it is cold?!
Do I understand sth. wrong here?

Uwe

No animation

Hi,

I tried to recreate your project.
I also used an old rpi2 with a raspberry pi os lite installation (no gui).

I had to manually copy the header and libs for open gl because the opt/vc folder was non existent and activate opengl in raspi config.

The triangle example worked. Your program showed the first gray image for 5 seconds on the 3 panels. . But there was no animation. I tried fiddling around, but nothing worked.

Do you have any ideas?

Problem with PrusaSlicer

Hello, the sides.stl file (the empty frame) does not slice in PrusaSlicer. It does in Cura, but it won't print right. I am a bit noob in 3d printing and do not know how to fix this.

Photo Trap: HTTP 501 Not Implemented

I was trying to get the photo trap working on an a6300 but all the camera returned was HTTP 501 (Not Implemented). I tried several other method strings in the JSON payload as well, which I extracted from the iOS sample app, but all of them return 501. The camera remains on "Connecting...", so there might be some initial request necessary? Do you have any idea what that might be about?

Auto blank timer patch

As I failed to properly add over on Reddit.

--- cpu-stats-gl.cpp.dist	2020-11-15 14:53:54.078672547 -0800
+++ cpu-stats-gl.cpp.timer.dist	2020-11-28 15:43:10.110640109 -0800
@@ -16,23 +16,38 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 
+// Define interval for auto blanking - set to zero to disable
+#define BLANKINTERVAL 12
+
+//UDP port to listen for status updates
 #define PORT 1234
+
+//Animation speed
 #define ANIMSTEP 0.5
 
-const int w = 192;
-const int h = 64;
+//Resolution, three panels with 64x64 each.
+#define W 192
+#define H 64
+
+//Number of CPU cores (or threads) to be represented on the ring
+#define CORES 16
+
+//Temperature thresholds for cool (blue), medium (green/yellow) and hot (red)
+#define T1 40.0 //Do not omit the decimal point. This will be used in the OpenGL shader which will otherwise interpret it as a float literal
+#define T2 60.0
+#define T3 80.0
+
+//That's it up here, but you might also want to change the settings for your RGB matrix in line 462 below
 
-using rgb_matrix::GPIO;
 using rgb_matrix::RGBMatrix;
 using rgb_matrix::Canvas;
 
 using namespace rgb_matrix;
 
-const int cores = 12;
 float temperature = 30.f;
-float cpu[cores] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+float cpu[CORES];
 float ttemperature = 30.f;
-float tcpu[cores] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+float tcpu[CORES];
 
 float t = 0.f;
 float updateTime = -10.0f;
@@ -54,9 +69,9 @@
 // Width and height of the desired framebuffer
 static const EGLint pbufferAttribs[] = {
     EGL_WIDTH,
-    w,
+    W,
     EGL_HEIGHT,
-    h,
+    H,
     EGL_NONE,
 };
 
@@ -141,6 +156,7 @@
 };
 
 #define STRINGIFY(x) #x
+#define RESTRINGIFY(x) STRINGIFY(x)
 static const char *vertexShaderCode = STRINGIFY(
     attribute vec3 pos;
     attribute vec2 coord;
@@ -151,9 +167,13 @@
     }
 );
 
-static const char *fragmentShaderCode = STRINGIFY(
+static const char *fragmentShaderCode1 = STRINGIFY(
+    const int CORES = ) RESTRINGIFY(CORES) STRINGIFY(;
+    const float T1 = ) RESTRINGIFY(T1) STRINGIFY(;
+    const float T2 = ) RESTRINGIFY(T2) STRINGIFY(;
+    const float T3 = ) RESTRINGIFY(T3) STRINGIFY(;
     uniform float temperature;
-    uniform float cpu[12];
+    uniform float cpu[CORES];
     vec3 mcolor = vec3(0.1, 0.6, 0.4);
     vec3 mcolorwarm = vec3(0.5, 0.5, 0.1);
     vec3 mcolorhot = vec3(0.6, 0.2, 0.1);
@@ -175,22 +195,14 @@
 
     void main() {
         vec2 coords = fragCoord.xy*0.5;
-        float phi = (atan(coords.y, coords.x)+3.1415926538)/3.1415926538*6.0;
+        float phi = (atan(coords.y, coords.x)+3.1415926538)/3.1415926538*float(CORES)*0.5;
+);
 
-        cpuf += clamp(1.0-abs(phi-0.0), 0.0, 1.0)*cpu[0];
-        cpuf += clamp(1.0-abs(phi-1.0), 0.0, 1.0)*cpu[1];
-        cpuf += clamp(1.0-abs(phi-2.0), 0.0, 1.0)*cpu[2];
-        cpuf += clamp(1.0-abs(phi-3.0), 0.0, 1.0)*cpu[3];
-        cpuf += clamp(1.0-abs(phi-4.0), 0.0, 1.0)*cpu[4];
-        cpuf += clamp(1.0-abs(phi-5.0), 0.0, 1.0)*cpu[5];
-        cpuf += clamp(1.0-abs(phi-6.0), 0.0, 1.0)*cpu[6];
-        cpuf += clamp(1.0-abs(phi-7.0), 0.0, 1.0)*cpu[7];
-        cpuf += clamp(1.0-abs(phi-8.0), 0.0, 1.0)*cpu[8];
-        cpuf += clamp(1.0-abs(phi-9.0), 0.0, 1.0)*cpu[9];
-        cpuf += clamp(1.0-abs(phi-10.0), 0.0, 1.0)*cpu[10];
-        cpuf += clamp(1.0-abs(phi-11.0), 0.0, 1.0)*cpu[11];
-        cpuf += clamp(1.0-abs(phi-12.0), 0.0, 1.0)*cpu[0];
+void fragmentShaderCodeLoop(char *str, int i) {
+    sprintf(str, "cpuf += clamp(1.0-abs(phi-%d.0), 0.0, 1.0)*cpu[%d];", i, i % CORES);
+}
 
+static const char *fragmentShaderCode2 = STRINGIFY(
         vec2 p = fragCoord.xy * 0.5 * 10.0 - vec2(19.0);
         vec2 i = p;
         float c = 1.0;
@@ -205,7 +217,7 @@
         c /= 8.0;
         c = 1.5 - sqrt(pow(c, 2.0));
         mcolor.g = clamp(coords.x, 0.0, 1.0);
-        mcolor = smoothstep(60.0, 40.0, temperature)*mcolor + smoothstep(40.0, 60.0, temperature)*smoothstep(80.0, 60.0, temperature)*mcolorwarm + smoothstep(60.0, 80.0, temperature)*mcolorhot;
+        mcolor = smoothstep(T2, T1, temperature)*mcolor + smoothstep(T1, T2, temperature)*smoothstep(T3, T2, temperature)*mcolorwarm + smoothstep(T2, T3, temperature)*mcolorhot;
          
         ccolor = smoothstep(50.0, 0.0, cpuf)*ccolor + smoothstep(0.0, 50.0, cpuf)*smoothstep(100.0, 50.0, cpuf)*ccolorwarm + smoothstep(50.0, 100.0, cpuf)*ccolorhot;
         ccolor *= circle(coords, 0.25, 0.01);
@@ -269,6 +281,15 @@
     return "Unknown error!";
 }
 
+std::string asString (const std::chrono::system_clock::time_point& tp)
+{
+     // convert to system time:
+     std::time_t t = std::chrono::system_clock::to_time_t(tp);
+     std::string ts = std::ctime(&t);// convert to calendar time
+     ts.resize(ts.size()-1);         // skip trailing newline
+     return ts;
+}
+
 #define BUFLEN 512
 void receiveUDP() {
     struct sockaddr_in si_me, si_other;
@@ -322,7 +343,7 @@
                             break;
                     default:
                             int k = j-1;
-                            if (k >= cores)
+                            if (k >= CORES)
                                 break;
                             tcpu[k] = entry;
                             break;
@@ -338,6 +359,21 @@
     }
 }
 
+bool checkShader(GLuint shader) {
+    GLint success = 0;
+    glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
+    if (success == GL_FALSE) {
+	    GLint length = 0;
+	    glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
+
+	    std::vector<GLchar> errorLog(length);
+	    glGetShaderInfoLog(shader, length, &length, &errorLog[0]);
+        fprintf(stderr, "Shader compilation failed!\n%s\n", errorLog);
+        return false;
+    }
+    return true;
+}
+
 int main(int argc, char *argv[]) {
     EGLDisplay display;
     int major, minor;
@@ -416,9 +452,25 @@
     vert = glCreateShader(GL_VERTEX_SHADER);
     glShaderSource(vert, 1, &vertexShaderCode, NULL);
     glCompileShader(vert);
+    if (!checkShader(vert))
+        return EXIT_FAILURE;
+
+    const int codelength = strlen(fragmentShaderCode1) + (CORES+1)*60 + strlen(fragmentShaderCode2);
+    char fragmentShaderCode[codelength];
+    strcpy(fragmentShaderCode, fragmentShaderCode1);
+    for (int i = 0; i <= CORES; i++) {
+        char loopCode[60];
+        fragmentShaderCodeLoop(loopCode, i);
+        strcat(fragmentShaderCode, loopCode);
+    }
+    strcat(fragmentShaderCode, fragmentShaderCode2);
+    static const char * cFragmentShaderCode = fragmentShaderCode;
+
     frag = glCreateShader(GL_FRAGMENT_SHADER);
-    glShaderSource(frag, 1, &fragmentShaderCode, NULL);
+    glShaderSource(frag, 1, &cFragmentShaderCode, NULL);
     glCompileShader(frag);
+    if (!checkShader(frag))
+        return EXIT_FAILURE;
     glAttachShader(program, frag);
     glAttachShader(program, vert);
     glLinkProgram(program);
@@ -469,47 +521,60 @@
     runtime.gpio_slowdown = 0;
     RGBMatrix *matrix = rgb_matrix::CreateMatrixFromFlags(&argc, &argv, &defaults, &runtime);
     if (matrix == NULL)
-        return 1;
+        return EXIT_FAILURE;
     FrameCanvas *canvas = matrix->CreateFrameCanvas();
 
     signal(SIGTERM, InterruptHandler);
     signal(SIGINT, InterruptHandler);
 
-    unsigned char *buffer = (unsigned char *)malloc(w * h * 3);
+    unsigned char *buffer = (unsigned char *)malloc(W * H * 3);
 
     std::thread networking(receiveUDP);
 
+    for (int i = 0; i < CORES; i++) {
+        cpu[i] = 0.0;
+        tcpu[i] = 0.0;
+    }
+
     while (!interrupt_received) {
 
         t += 0.01f;
-        glUniform1f(timeLoc, t);
-        glUniform1f(ageLoc, float(t - updateTime));
 
-        if (ttemperature > temperature)
-            temperature += 0.2*ANIMSTEP;
-        if (ttemperature < temperature)
-            temperature -= 0.2*ANIMSTEP;
-        for (int i = 0; i < cores; i++) {
-            if (tcpu[i] > cpu[i])
-                cpu[i] += ANIMSTEP;
-            if (tcpu[i] < cpu[i])
-                cpu[i] -= ANIMSTEP;
-        }
-
-        glUniform1f(temperatureLoc, temperature);
-        glUniform1fv(cpuLoc, cores, cpu);
-
-        glDrawArrays(GL_TRIANGLE_STRIP, 0, 12);
-        glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, buffer);
+        // Grab the interval since last update
+        int quiet = int(t - updateTime);
 
-        for (int x = 0; x < w; x++) {
-            for (int y = 0; y < h; y++) {
-                int index = 3*(x+y*w);
-                canvas->SetPixel(x, y, buffer[index], buffer[index+1], buffer[index+2]);
-            }
+        // If we haven't heard anything for BLANKINTERVAL then don't update, blank the canvas and sleep for five seconds
+        if ((quiet > BLANKINTERVAL) && (BLANKINTERVAL > 0)){
+          canvas = matrix->SwapOnVSync(canvas);
+          canvas->Clear();
+          sleep(5);
+        } else {
+
+	        glUniform1f(timeLoc, t);
+        	glUniform1f(ageLoc, float(t - updateTime));
+
+	        if (ttemperature > temperature)
+	            temperature += 0.2*ANIMSTEP;
+	        if (ttemperature < temperature)
+	            temperature -= 0.2*ANIMSTEP;
+	        for (int i = 0; i < CORES; i++) {
+	            if (tcpu[i] > cpu[i])
+	                cpu[i] += ANIMSTEP;
+	            if (tcpu[i] < cpu[i])
+	                cpu[i] -= ANIMSTEP;
+	        }
+	        glUniform1f(temperatureLoc, temperature);
+	        glUniform1fv(cpuLoc, CORES, cpu);
+	        glDrawArrays(GL_TRIANGLE_STRIP, 0, 12);
+	        glReadPixels(0, 0, W, H, GL_RGB, GL_UNSIGNED_BYTE, buffer);
+	        for (int x = 0; x < W; x++) {
+	            for (int y = 0; y < H; y++) {
+	                int index = 3*(x+y*W);
+	                canvas->SetPixel(x, y, buffer[index], buffer[index+1], buffer[index+2]);
+	            }
+	        }
+	        canvas = matrix->SwapOnVSync(canvas);
         }
-
-        canvas = matrix->SwapOnVSync(canvas);
     }
 
     networking.join();

Confusing compile error

I'm getting a compile failure which I assume is me doing something dumb. This looks like a namespace error or missing library, though I do have rpi-rgb-led-matrix ostensibly installed at the specified paths. Verbose output from g++ isn't telling me anything beyond the error seen here.

`pi@cubepi:~ $ g++ -g -o cpu-stats-gl cpu-stats-gl.cpp -std=c++11 -lbrcmEGL -lbrcmGLESv2 -I/opt/vc/include -L/opt/vc/lib -Lrpi-rgb-led-matrix/lib -lrgbmatrix -lrt -lm -lpthread -lstdc++ -Irpi-rgb-led-matrix/include/

cpu-stats-gl.cpp:25:19: error: 'rgb_matrix::GPIO' has not been declared

using rgb_matrix::GPIO;`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.