![]() |
Forum Index : Microcontroller and PC projects : IMAGE ROTATE
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10070 |
You need to write a bigger area to the colour you want where you are going to output the text. The rotate is rotating an area that includes not just the text but the other junk as well. This is just a simple programming bug |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks, I'll try and work that out :) |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I'm trying to get my head around this IMAGE ROTATEx, y, width, height, new_x, new_y, angle!, remove black triangle artifact Text 10,10,"NE" Image rotate 6,4,30,30, new_x, new_y, angle! that means it's picking up a rectangle 30 x 30 with the word NE in it? Then rotating that by angle and placing it in the new position? That's why it's using the grey colour instead of the blue because at the original location the colour is grey Yet when I do Text 540,110,"NE" so it picks up the correct colour it Still prints a blank box with the grey colour If I experiment and try and do as you say and use larger area to write to it just makes the grey boxes larger It's possibly because I can't get my head around "exactly" what it's doing |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10070 |
Because you haven't changed the address where the rotate is sourcing the data USE the BOX command to write a blue box at 0,0. Then use the original code. Once the rotates are done Rewrite the blue box to grey You can see the effect with the attached Option explicit CLS RGB(gray) Box 0,0,50,50,0,RGB(134,174,230),RGB(134,174,230) Dim cx% = 785 Dim cy% = 238 Dim wid% = 105 Dim ang! = 0.087266463 Dim rad90! = 1.570796327 '90 degrees in radians compass_rose 625,475,75 Sub compass_rose cx%,cy%,wid% Local a% Text cx%+9,cy%+15-(wid%+22),"N",L,4,,RGB(1,1,1),RGB(134,174,230) Text cx%+9,cy%+15+(wid%+5),"S",L,4,,RGB(1,1,1),RGB(134,174,230) Text cx%+wid%+18,cy%+4,"E",L,4,,RGB(1,1,1),RGB(134,174,230) Text cx%-(wid%+5),cy%+4,"W",L,4,,RGB(1,1,1),RGB(134,174,230) Text 10,10,"NE",L,7,,RGB(1,1,1),RGB(134,174,230) Image rotate 6,4,30,30,cx%+(wid%-16)*Cos(.785),cy%-(wid%-16)*Cos(.785),45,1 Text 10,10,"SE",L,7,,RGB(1,1,1),RGB(134,174,230) Image rotate 6,4,30,30,cx%+(wid%-16)*Cos(.785),cy%+(wid%-16)*Cos(.785),135,1 Text 10,10,"SW",L,7,,RGB(1,1,1),RGB(134,174,230) Image rotate 6,4,30,30,cx%-(wid%-16)*Cos(.785),cy%+(wid%-16)*Cos(.785),225,1 Text 10,10,"NW",L,7,,RGB(1,1,1),RGB(134,174,230) Image rotate 6,4,29,29,cx%-(wid%-16)*Cos(.785),cy%-(wid%-16)*Cos(.785),315,1 Text 10,10," ",L,7,,RGB(134,174,230),RGB(134,174,230) ' clear text ' tick marks, every 5 degrees (360/5 = 72) For a% = 0 To 71 Line (cx%+15)+(Cos(a%*ang!)*(wid%-4)),(cy%+15)-(Sin(a%*ang!)*(wid%-4)),(cx%+15)+(Cos(a%*ang!)*(wid%+1)),(cy%+15)-(Sin(a%*ang!)*(wid%+1)),,RGB(WHITE) Next ' compass perimiter Circle cx%+15,cy%+15,wid% Circle cx%+15,cy%+15,wid%-4 End Sub |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thank you, that works perfectly I don't get why it needed the box but I'll work on it and try and figure that out myself btw that other error I mentioned is still happening, I've narrowed it down to one section of code SUB Forecast LONGSTRING PRINT c() conditions$ = JSON$(c(),"current_conditions.conditions") print conditions$ I actually thought it would do the longstring print before it went on to the JSON$ edit: if I type run straight away it then runs fine till the next time, I suspect it might be something wrong in the data being received so I'm going to do the longstring print straight after wget and see how that goes Edited 2021-01-11 00:22 by lew247 |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I thought it might be the buffer for c() wasn't large enough and was not getting the end }}, I had it at 15000 I then counted the characters received and there was 93885, it should have been enough but I've upped it to 16K just in case |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 3999 |
Maybe add a delay after each line to make sure any print buffering has finished. John |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10070 |
Lewis Please try the attached and see if it makes the crashing better or worse mmbasic.zip |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Sorry Peter, it crashed again first time I pressed run I deleted the old mmbasic, and .options transferred this version and got this immediately Edit: Without doing anything else I pressed run and it ran, same as before btw it was around secs = 17 when I pressed run the first time so it shouldn't have tried to get the JSON data Edited 2021-01-11 05:49 by lew247 |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Edit 2 After it collected the data It came up with this |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10070 |
Ok - that's useful. It looks like the json you are trying to load is simply too big and/or complex for the parser. Nothing I can do about it I'm afraid |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I really hate to disagree with such an expert but I have to with this. The Pi and Picromite is definitely able to handle the data and parsing. The old version 5.05.01 worked perfectly for days with no issues, the only thing wrong was Blit and image rotate didn't work Blit I discovered was my fault because I didn't know it had been changed to three parameters and not 4 I checked this by loading it up again and running it overnight, over 12 hours so far with no crashes The only thing missing was Image rotate This version worked best out of all the ones you did yesterday, it ran for several hours before crashing and throwing this error If I close the terminal and do screen -D -r it goes back to the error and won't do anything until I close the terminal again The only way to gain control of the Pi again is close the terminal, log back in and reboot. However, thank you so so much for trying :) I can get away without the image rotate function by using miniature images with the words inside rotated to the correct angle. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10070 |
Lewis Please could you try the attached. I've updated the JSON parser to the latest version. This includes bug fixes of both memory leaks and buffer overflow conditions that may relate to the issues you are seeing. I've run it on a simple test program for an extended period without issue mmbasic.zip |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
running it now, using the latest version of Stretch lite available, and updated fully and the latest pigpio |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Peter it's working perfectly for over 2 hours so far. It did crash the very first time I press run but it was also a new install of the latest Stretch, Pigpio and python3-distutils on a clean SD card. I took a screenshot in case it's any help I also tried it on a new install on a clean SD card with the latest Pi OS lite on my Pi 4 but it didn't run pi@Pi4:~ $ sudo ./mmbasic ./mmbasic: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory Edited 2021-01-13 21:58 by lew247 |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I spoke too soon it crashed after almost 3 hours |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10070 |
Please run it on the version of stretch that you posted - any upgrades are likely to break it - this is exactly the problem with the whole Pi infrastructure |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
ok will do it will take a moment to load it again original version of pigpio as well? |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10070 |
Definitely - this is even more important |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Ran beautifully first time yock1960 if you see this I sent you a pm |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |