Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psy0rz committed Dec 24, 2024
1 parent a2ac920 commit 60c1e17
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
34 changes: 16 additions & 18 deletions ledder/server/RenderRealtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {Render} from "./Render.js"
export class RenderRealtime extends Render {

private nextTimeMicros: number
private lastFrameMicros: number

private keepRendering: boolean

Expand All @@ -24,7 +23,6 @@ export class RenderRealtime extends Render {
if (!this.keepRendering) {
this.keepRendering = true
this.nextTimeMicros = Date.now() * 1000
this.lastFrameMicros = 0
this.lastStatUpdate=Date.now()

this.lateFrames=0
Expand All @@ -47,29 +45,29 @@ export class RenderRealtime extends Render {
this.nextTimeMicros+= await this.scheduler.__step(true)

//max 10 frames difference
if (Math.abs(this.nextTimeMicros-nowUS)>this.scheduler.__frameTimeMicros*10) {

let diffUS=this.nextTimeMicros-nowUS

//too slow, or other clock problem
if (Math.abs(this.nextTimeMicros-nowUS)>this.scheduler.__frameTimeMicros*2) {
//reset
this.nextTimeMicros = nowUS+this.scheduler.__frameTimeMicros;
this.nextTimeMicros = nowUS+this.scheduler.__frameTimeMicros
this.droppedFrames++
}

if ( nowUS-this.lastFrameMicros >= this.display.minFrameTimeMicros) {
try {
this.display.render(this.box)
} catch (e) {
console.error("Exception while rendering:", e)
}
this.display.frame(this.nextTimeMicros)
this.lastFrameMicros = nowUS
}
else
{
this.droppedFrames++;
try {
this.display.render(this.box)
} catch (e) {
console.error("Exception while rendering:", e)
}
this.display.frame(this.nextTimeMicros)

if (nowUS-this.lastStatUpdate>1000000)
{

console.log(`RenderRealtime: ${this.lateFrames} late. ${this.droppedFrames} dropped. ${ Math.round( ( 1000-this.idleMS)/10) }% busy.`)
let busy=Math.round( ( 1000-this.idleMS)/10)
if (busy<0)
busy=0
console.log(`RenderRealtime: ${this.lateFrames} late. ${this.droppedFrames} dropped. ${ busy }% busy.`)
this.lastStatUpdate=nowUS
this.droppedFrames=0;
this.lateFrames=0;
Expand Down
4 changes: 2 additions & 2 deletions ledder/server/drivers/DisplayQOISudp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DisplayQOISudp extends DisplayQOIS {
* @param pixelsPerChannel Number of pixels per channel you want to use. Doesnt have to correspondent with how you compiled ledder, leds will be skipped/cropped. Or 0 to use all the leds available in the firmware.
* @param maxFps Maximum frames per second. This depends on the total leds and leds per channel (512 leds per channel is max 58fps or less). We use 50fps to be on the safe side. Keep an eye ledstream and see if the udpbuffer keeps overflowing.
*/
constructor(mapper: OffsetMapper, ips, port, pixelsPerChannel = 0, maxFps=50) {
constructor(mapper: OffsetMapper, ips, port, pixelsPerChannel = 0, maxFps=60) {
super(mapper, pixelsPerChannel)


Expand Down Expand Up @@ -91,7 +91,7 @@ export class DisplayQOISudp extends DisplayQOIS {

const frameBytes = []

const maxFramesLag = 12
const maxFramesLag = 24
const maxTimeLag = 250

//buffer this many frames
Expand Down

0 comments on commit 60c1e17

Please sign in to comment.