@@ -264,7 +264,7 @@ func calculateIntXY(fontSize float64, value int) (int, int) {
264
264
}
265
265
266
266
func calculateStringXY (fontSize float64 , value string ) (int , int ) {
267
- opts := opentype.FaceOptions {Size : fontSize , DPI : 72 , Hinting : 2 }
267
+ opts := opentype.FaceOptions {Size : fontSize , DPI : 72 , Hinting : 0 }
268
268
fontFace , err := opentype .NewFace (lcd .sfntFont , & opts )
269
269
if err != nil {
270
270
logger .Log (logger.Fields {"error" : err }).Error ("Unable to process font face" )
@@ -298,99 +298,99 @@ func GenerateScreenImage(imageType uint8, value, value1, value2, value3 int) []b
298
298
case DisplayLiquid :
299
299
{
300
300
x , y := calculateStringXY (40 , "LIQUID TEMP" )
301
- drawString (x , y - 120 , 40 , c , "LIQUID TEMP" , rgba )
301
+ drawString (x , y - 120 , 40 , "LIQUID TEMP" , rgba )
302
302
303
303
x , y = calculateStringXY (40 , "[ °C ]" )
304
- drawString (x , y + 120 , 40 , c , "[ °C ]" , rgba )
304
+ drawString (x , y + 120 , 40 , "[ °C ]" , rgba )
305
305
306
306
x , y = calculateStringXY (240 , strconv .Itoa (value ))
307
- drawString (x , y , 240 , c , strconv .Itoa (value ), rgba )
307
+ drawString (x , y , 240 , strconv .Itoa (value ), rgba )
308
308
}
309
309
case DisplayGPU :
310
310
{
311
311
x , y := calculateStringXY (40 , "GPU TEMP" )
312
- drawString (x , y - 120 , 40 , c , "GPU TEMP" , rgba )
312
+ drawString (x , y - 120 , 40 , "GPU TEMP" , rgba )
313
313
314
314
x , y = calculateStringXY (40 , "[ °C ]" )
315
- drawString (x , y + 120 , 40 , c , "[ °C ]" , rgba )
315
+ drawString (x , y + 120 , 40 , "[ °C ]" , rgba )
316
316
317
317
x , y = calculateStringXY (240 , strconv .Itoa (value ))
318
- drawString (x , y , 240 , c , strconv .Itoa (value ), rgba )
318
+ drawString (x , y , 240 , strconv .Itoa (value ), rgba )
319
319
}
320
320
case DisplayCPU :
321
321
{
322
322
x , y := calculateStringXY (40 , "CPU TEMP" )
323
- drawString (x , y - 120 , 40 , c , "CPU TEMP" , rgba )
323
+ drawString (x , y - 120 , 40 , "CPU TEMP" , rgba )
324
324
325
325
x , y = calculateStringXY (40 , "[ °C ]" )
326
- drawString (x , y + 120 , 40 , c , "[ °C ]" , rgba )
326
+ drawString (x , y + 120 , 40 , "[ °C ]" , rgba )
327
327
328
328
x , y = calculateStringXY (240 , strconv .Itoa (value ))
329
- drawString (x , y , 240 , c , strconv .Itoa (value ), rgba )
329
+ drawString (x , y , 240 , strconv .Itoa (value ), rgba )
330
330
}
331
331
case DisplayPump :
332
332
{
333
333
x , y := calculateStringXY (40 , "PUMP SPEED" )
334
- drawString (x , y - 120 , 40 , c , "PUMP SPEED" , rgba )
334
+ drawString (x , y - 120 , 40 , "PUMP SPEED" , rgba )
335
335
336
336
x , y = calculateStringXY (40 , "[ RPM ]" )
337
- drawString (x , y + 120 , 40 , c , "[ RPM ]" , rgba )
337
+ drawString (x , y + 120 , 40 , "[ RPM ]" , rgba )
338
338
339
339
x , y = calculateStringXY (200 , strconv .Itoa (value ))
340
- drawString (x , y , 200 , c , strconv .Itoa (value ), rgba )
340
+ drawString (x , y , 200 , strconv .Itoa (value ), rgba )
341
341
}
342
342
case DisplayAllInOne :
343
343
{
344
344
x , y := calculateStringXY (40 , "LIQUID" )
345
- drawString (x - 80 , y - 110 , 40 , c , "LIQUID" , rgba )
345
+ drawString (x - 80 , y - 110 , 40 , "LIQUID" , rgba )
346
346
347
347
x , y = calculateStringXY (40 , "CPU" )
348
- drawString (x + 80 , y - 110 , 40 , c , "CPU" , rgba )
348
+ drawString (x + 80 , y - 110 , 40 , "CPU" , rgba )
349
349
350
350
x , y = calculateStringXY (40 , "PUMP" )
351
- drawString (x , y + 130 , 40 , c , "PUMP" , rgba )
351
+ drawString (x , y + 130 , 40 , "PUMP" , rgba )
352
352
353
353
x , y = calculateStringXY (100 , strconv .Itoa (value ))
354
- drawString (x - 80 , y - 40 , 100 , c , strconv .Itoa (value ), rgba )
354
+ drawString (x - 80 , y - 40 , 100 , strconv .Itoa (value ), rgba )
355
355
356
356
x , y = calculateStringXY (100 , strconv .Itoa (value1 ))
357
- drawString (x + 80 , y - 40 , 100 , c , strconv .Itoa (value1 ), rgba )
357
+ drawString (x + 80 , y - 40 , 100 , strconv .Itoa (value1 ), rgba )
358
358
359
359
x , y = calculateStringXY (100 , strconv .Itoa (value2 ))
360
- drawString (x , y + 60 , 100 , c , strconv .Itoa (value2 ), rgba )
360
+ drawString (x , y + 60 , 100 , strconv .Itoa (value2 ), rgba )
361
361
}
362
362
case DisplayLiquidCPU :
363
363
{
364
- drawString (120 + int (c .PointToFixed (24 )>> 6 ), 110 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "LIQUID" , rgba )
365
- drawString (280 + int (c .PointToFixed (24 )>> 6 ), 110 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "CPU" , rgba )
366
- drawString (190 + int (c .PointToFixed (24 )>> 6 ), 350 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "[ °C ]" , rgba )
367
- drawString (95 + int (c .PointToFixed (24 )>> 6 ), 270 + int (c .PointToFixed (24 )>> 6 ), 160 , c , strconv .Itoa (value ), rgba )
368
- drawString (250 + int (c .PointToFixed (24 )>> 6 ), 270 + int (c .PointToFixed (24 )>> 6 ), 160 , c , strconv .Itoa (value1 ), rgba )
364
+ drawString (120 + int (c .PointToFixed (24 )>> 6 ), 110 + int (c .PointToFixed (24 )>> 6 ), 40 , "LIQUID" , rgba )
365
+ drawString (280 + int (c .PointToFixed (24 )>> 6 ), 110 + int (c .PointToFixed (24 )>> 6 ), 40 , "CPU" , rgba )
366
+ drawString (190 + int (c .PointToFixed (24 )>> 6 ), 350 + int (c .PointToFixed (24 )>> 6 ), 40 , "[ °C ]" , rgba )
367
+ drawString (95 + int (c .PointToFixed (24 )>> 6 ), 270 + int (c .PointToFixed (24 )>> 6 ), 160 , strconv .Itoa (value ), rgba )
368
+ drawString (250 + int (c .PointToFixed (24 )>> 6 ), 270 + int (c .PointToFixed (24 )>> 6 ), 160 , strconv .Itoa (value1 ), rgba )
369
369
}
370
370
case DisplayCpuGpuTemp :
371
371
{
372
- drawString (120 + int (c .PointToFixed (24 )>> 6 ), 120 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "CPU" , rgba )
373
- drawString (270 + int (c .PointToFixed (24 )>> 6 ), 120 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "GPU" , rgba )
374
- drawString (190 + int (c .PointToFixed (24 )>> 6 ), 350 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "[ °C ]" , rgba )
375
- drawString (90 + int (c .PointToFixed (24 )>> 6 ), 270 + int (c .PointToFixed (24 )>> 6 ), 160 , c , strconv .Itoa (value ), rgba )
376
- drawString (240 + int (c .PointToFixed (24 )>> 6 ), 270 + int (c .PointToFixed (24 )>> 6 ), 160 , c , strconv .Itoa (value1 ), rgba )
372
+ drawString (120 + int (c .PointToFixed (24 )>> 6 ), 120 + int (c .PointToFixed (24 )>> 6 ), 40 , "CPU" , rgba )
373
+ drawString (270 + int (c .PointToFixed (24 )>> 6 ), 120 + int (c .PointToFixed (24 )>> 6 ), 40 , "GPU" , rgba )
374
+ drawString (190 + int (c .PointToFixed (24 )>> 6 ), 350 + int (c .PointToFixed (24 )>> 6 ), 40 , "[ °C ]" , rgba )
375
+ drawString (90 + int (c .PointToFixed (24 )>> 6 ), 270 + int (c .PointToFixed (24 )>> 6 ), 160 , strconv .Itoa (value ), rgba )
376
+ drawString (240 + int (c .PointToFixed (24 )>> 6 ), 270 + int (c .PointToFixed (24 )>> 6 ), 160 , strconv .Itoa (value1 ), rgba )
377
377
}
378
378
case DisplayCpuGpuLoadTemp :
379
379
{
380
- drawString (130 + int (c .PointToFixed (24 )>> 6 ), 140 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "CPU" , rgba )
381
- drawString (270 + int (c .PointToFixed (24 )>> 6 ), 140 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "GPU" , rgba )
382
- drawString (190 + int (c .PointToFixed (24 )>> 6 ), 90 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "[ °C ]" , rgba )
383
- drawString (190 + int (c .PointToFixed (24 )>> 6 ), 350 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "[ % ]" , rgba )
384
- drawString (120 + int (c .PointToFixed (24 )>> 6 ), 220 + int (c .PointToFixed (24 )>> 6 ), 80 , c , fmt .Sprintf ("%02d" , value ), rgba )
385
- drawString (260 + int (c .PointToFixed (24 )>> 6 ), 220 + int (c .PointToFixed (24 )>> 6 ), 80 , c , fmt .Sprintf ("%02d" , value1 ), rgba )
386
- drawString (120 + int (c .PointToFixed (24 )>> 6 ), 290 + int (c .PointToFixed (24 )>> 6 ), 80 , c , fmt .Sprintf ("%02d" , value2 ), rgba )
387
- drawString (260 + int (c .PointToFixed (24 )>> 6 ), 290 + int (c .PointToFixed (24 )>> 6 ), 80 , c , fmt .Sprintf ("%02d" , value3 ), rgba )
380
+ drawString (130 + int (c .PointToFixed (24 )>> 6 ), 140 + int (c .PointToFixed (24 )>> 6 ), 40 , "CPU" , rgba )
381
+ drawString (270 + int (c .PointToFixed (24 )>> 6 ), 140 + int (c .PointToFixed (24 )>> 6 ), 40 , "GPU" , rgba )
382
+ drawString (190 + int (c .PointToFixed (24 )>> 6 ), 90 + int (c .PointToFixed (24 )>> 6 ), 40 , "[ °C ]" , rgba )
383
+ drawString (190 + int (c .PointToFixed (24 )>> 6 ), 350 + int (c .PointToFixed (24 )>> 6 ), 40 , "[ % ]" , rgba )
384
+ drawString (120 + int (c .PointToFixed (24 )>> 6 ), 220 + int (c .PointToFixed (24 )>> 6 ), 80 , fmt .Sprintf ("%02d" , value ), rgba )
385
+ drawString (260 + int (c .PointToFixed (24 )>> 6 ), 220 + int (c .PointToFixed (24 )>> 6 ), 80 , fmt .Sprintf ("%02d" , value1 ), rgba )
386
+ drawString (120 + int (c .PointToFixed (24 )>> 6 ), 290 + int (c .PointToFixed (24 )>> 6 ), 80 , fmt .Sprintf ("%02d" , value2 ), rgba )
387
+ drawString (260 + int (c .PointToFixed (24 )>> 6 ), 290 + int (c .PointToFixed (24 )>> 6 ), 80 , fmt .Sprintf ("%02d" , value3 ), rgba )
388
388
}
389
389
case DisplayCpuGpuLoad :
390
390
{
391
- drawString (120 + int (c .PointToFixed (24 )>> 6 ), 120 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "CPU" , rgba )
392
- drawString (270 + int (c .PointToFixed (24 )>> 6 ), 120 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "GPU" , rgba )
393
- drawString (190 + int (c .PointToFixed (24 )>> 6 ), 350 + int (c .PointToFixed (24 )>> 6 ), 40 , c , "[ % ]" , rgba )
391
+ drawString (120 + int (c .PointToFixed (24 )>> 6 ), 120 + int (c .PointToFixed (24 )>> 6 ), 40 , "CPU" , rgba )
392
+ drawString (270 + int (c .PointToFixed (24 )>> 6 ), 120 + int (c .PointToFixed (24 )>> 6 ), 40 , "GPU" , rgba )
393
+ drawString (190 + int (c .PointToFixed (24 )>> 6 ), 350 + int (c .PointToFixed (24 )>> 6 ), 40 , "[ % ]" , rgba )
394
394
395
395
reduce := 0
396
396
bounds , _ := font .BoundString (basicfont .Face7x13 , strconv .Itoa (value ))
@@ -399,23 +399,23 @@ func GenerateScreenImage(imageType uint8, value, value1, value2, value3 int) []b
399
399
reduce = 30
400
400
}
401
401
x := 100 + textWidth - reduce
402
- drawString (x , 270 + int (c .PointToFixed (24 )>> 6 ), 160 , c , fmt .Sprintf ("%02d" , value ), rgba )
402
+ drawString (x , 270 + int (c .PointToFixed (24 )>> 6 ), 160 , fmt .Sprintf ("%02d" , value ), rgba )
403
403
404
404
bounds , _ = font .BoundString (basicfont .Face7x13 , strconv .Itoa (value1 ))
405
405
textWidth = (bounds .Max .X - bounds .Min .X ).Floor ()
406
406
if value == 100 {
407
407
reduce = 30
408
408
}
409
409
x = 240 + textWidth + 15 - reduce
410
- drawString (x , 270 + int (c .PointToFixed (24 )>> 6 ), 160 , c , fmt .Sprintf ("%02d" , value1 ), rgba )
410
+ drawString (x , 270 + int (c .PointToFixed (24 )>> 6 ), 160 , fmt .Sprintf ("%02d" , value1 ), rgba )
411
411
}
412
412
case DisplayTime :
413
413
{
414
414
x , y := calculateStringXY (70 , common .GetDate ())
415
- drawString (x , y - 50 , 70 , c , common .GetDate (), rgba )
415
+ drawString (x , y - 50 , 70 , common .GetDate (), rgba )
416
416
417
417
x , y = calculateStringXY (130 , common .GetTime ())
418
- drawString (x , y + 50 , 130 , c , common .GetTime (), rgba )
418
+ drawString (x , y + 50 , 130 , common .GetTime (), rgba )
419
419
}
420
420
}
421
421
@@ -444,14 +444,13 @@ func drawString(x, y int, fontSite float64, c *freetype.Context, text string) *f
444
444
*/
445
445
446
446
// drawString will create a new string for image
447
- func drawString (x , y int , fontSite float64 , c * freetype.Context , text string , rgba * image.RGBA ) {
448
- c .SetFontSize (fontSite )
447
+ func drawString (x , y int , fontSite float64 , text string , rgba * image.RGBA ) {
449
448
pt := freetype .Pt (x , y )
450
-
451
449
opts := opentype.FaceOptions {Size : fontSite , DPI : 72 , Hinting : 0 }
452
450
fontFace , err := opentype .NewFace (lcd .sfntFont , & opts )
453
451
if err != nil {
454
452
logger .Log (logger.Fields {"error" : err }).Error ("Unable to process font face" )
453
+ return
455
454
}
456
455
d := & font.Drawer {
457
456
Dst : rgba ,
0 commit comments