Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:38 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMiteVGA Framebuffer question...

Author Message
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 396
Posted: 04:53pm 25 Mar 2023
Copy link to clipboard 
Print this post

Hello,

I am trying to understand the framebuffer and simply don't get it. All I want to do is this example Peter showed on YouTube (https://www.youtube.com/watch?v=dLk7JgB3YCY), where he has a background image and a moving sine wave on the top layer.

The manual is good, but does not help how to begin with.

I think first of all I have to load my desired image

load image "grid"


Then create a framebuffer with

framebuffer create


now (in my mind) I've created a framebuffer with my background image "grid"

Then I want to put my moving sine function on top of that with

framebuffer layer


Because the manual says: "Allocates 38400 bytes of variable memory to a second display layer. This
layer sits on top of the main display." So exactly what I want. now I am drawing my moving sine wave on top, but nothing works the screen goes black.


This is always my problem with complex commands, I read the manual, but I don't know how to start at all. Is there anywhere Peters YouTube example of it? I've looked at Martins framebuffer examples with sprites but they are all too complex to begin with.

My final application is my ECG, which works good but needs some grid in the background and I thought it would be much better with framebuffer than drawing horzontal and vertical lines.

This is my ECG, which works good so far, but a background grid would be much nicer.


SetTick 10, ekg_interrupt 'Abtastrate 100Hz
SetPin GP28, AIN
SetPin GP25, DOUT
Font 2,1
CLS c
RTC gettime

 'Tiefpass
  a0t =  0.1565712872
  a1t =  0.2651425745
  a2t =  0.1565712872
  b1t = -0.5695259524
  b2t =  0.1958111014

 'Notch
  a0n =  0.7857841106
  a1n = -8.4007020142E-16
  a2n =  0.7857841106
  b1n = -8.4007020142E-16
  b2n =  1.1915682213

Do
 If x>MM.HRes Then
   x=-1
   'Save image "bild.bmp"
 EndIf
Loop

ekg_interrupt:
 'Show Time
 Text 120,210,Time$
 'Increment
 x=x+1
 ekg = Pin(GP28)
 'Filter 1
 sn_2 = s_n1
 s_n1 = s_n
 s_n  = ekg
 g_n2 = g_n1
 g_n1 = g_n
 g_n  = s_n*a0t+s_n1*a1t+s_n2*a2t+g_n1*b1t+g_n2*b2t
 ekg  = g_n
 'Filter 2
 sn_2 = s_n1
 s_n1 = s_n
 s_n  = ekg
 g_n2 = g_n1
 g_n1 = g_n
 g_n  = s_n*a0n+s_n1*a1n+s_n2*a2n+g_n1*b1n+g_n2*b2n
 ekg  = g_n
 'Drawing
 Line x,0,x+1,MM.HRes,1,BF
 Line x-1,ekg_alt*140,x,ekg*140,1
 ekg_alt = ekg
IReturn







Greetings
Daniel
Edited 2023-03-26 03:08 by Amnesie
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 05:19pm 25 Mar 2023
Copy link to clipboard 
Print this post

MODE 2
FRAMEBUFFER create
FRAMEBUFFER layer
For x=1 To MM.HRes-1 Step 16
Line x,0,x,MM.VRes-1
Next
For y=1 To MM.VRes-1 Step 16
Line 0,y,MM.HRes-1,y
Next
i=0
Do
FRAMEBUFFER write f
CLS
For j=i To MM.HRes-1+i
l=k
k=Sin(j/MM.HRes*2*Pi)
If j<>i Then Line j-i-1,l*100+MM.VRes/2,j-i,k*100+MM.VRes/2,,RGB(red)
Next
Inc i
FRAMEBUFFER copy f,l,b
Loop

Edited 2023-03-26 03:27 by matherp
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 396
Posted: 07:02pm 25 Mar 2023
Copy link to clipboard 
Print this post

Thank you a lot, this helped me to understand how it works!    

Greetings
Daniel
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1115
Posted: 07:30pm 25 Mar 2023
Copy link to clipboard 
Print this post

Hi Daniel,

Framebuffer N is the actual screen

Framebuffer F is the Buffer which is never visible but you can hiddenly draw on it and copy it to Framebuffer N or L

Framebuffer L is a Layer, Everything that is written or drawn here is placed over the Screen like a foil without changing the content of screen(n)
(Like a 100% opaque Layer in Photoshop).An exception here are black pixels, these are transparent in the layer, so the content of the screen(n) "shines through" all black pixels on Framebuffer L

I hope that was somewhat understandable

for example look at my "on the road again" demo, here the screen is drawn hidden  on Framebuffer F and copied to N when ready,
the Car is shown on Framebuffer L so that it doesn't affect the background

Cheers
Mart!n
Edited 2023-03-26 05:55 by Martin H.
'no comment
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024