@@ -24,6 +24,7 @@ export class LCD1602Element extends LitElement {
24
24
@property ( ) cursorY = 0 ;
25
25
@property ( ) backlight = true ;
26
26
@property ( ) pins : 'full' | 'i2c' | 'none' = 'full' ;
27
+ @property ( ) screenOnly = false ;
27
28
28
29
protected numCols = 16 ;
29
30
protected numRows = 2 ;
@@ -221,8 +222,14 @@ export class LCD1602Element extends LitElement {
221
222
background in backgroundColors ? backgroundColors [ background ] : backgroundColors ;
222
223
223
224
const panelWidth = cols * 3.5125 ;
224
- const width = panelWidth + 23.8 ;
225
- const height = panelHeight + 24.5 ;
225
+ const width = this . screenOnly ? panelWidth : panelWidth + 23.8 ;
226
+ const height = this . screenOnly ? panelHeight : panelHeight + 24.5 ;
227
+
228
+ const panelX = 12.45 ;
229
+ const panelY = 12.55 ;
230
+ const viewBox = this . screenOnly
231
+ ? `${ panelX } ${ panelY } ${ panelWidth } ${ panelHeight } `
232
+ : `0 0 ${ width } ${ height } ` ;
226
233
227
234
// Dimensions according to:
228
235
// https://www.winstar.com.tw/products/character-lcd-display-module/16x2-lcd.html
@@ -231,7 +238,7 @@ export class LCD1602Element extends LitElement {
231
238
width ="${ width } mm "
232
239
height ="${ height } mm "
233
240
version ="1.1 "
234
- viewBox ="0 0 ${ width } ${ height } "
241
+ viewBox ="${ viewBox } "
235
242
style ="font-size: 1.5px; font-family: monospace "
236
243
xmlns ="http://www.w3.org/2000/svg "
237
244
>
@@ -277,13 +284,17 @@ export class LCD1602Element extends LitElement {
277
284
${ pins === 'i2c' ? this . renderI2CPins ( ) : null }
278
285
${ pins === 'full' ? this . renderPins ( panelHeight ) : null }
279
286
< rect
280
- x ="12.45 "
281
- y ="12.55 "
287
+ x ="${ panelX } "
288
+ y ="${ panelY } "
282
289
width ="${ panelWidth } "
283
290
height ="${ panelHeight } "
284
291
fill ="url(#characters) "
285
292
/>
286
- < path d ="${ this . path ( characters ) } " transform ="translate(12.45, 12.55) " fill ="${ color } " />
293
+ < path
294
+ d ="${ this . path ( characters ) } "
295
+ transform ="translate(${ panelX } , ${ panelY } ) "
296
+ fill ="${ color } "
297
+ />
287
298
${ this . renderCursor ( ) }
288
299
</ svg >
289
300
` ;
0 commit comments