Comments (9)
@juvus could you please take a look at this? it's related to your custom character implementation. (@Jumitti might be able to help as well. Feel free to chime in.)
from lcd.
Hi, sorry for late response. To redefine a custom character you need to pass a python list containing 7 strings as it is shown here:
cc.char_1_data = ["01110", "01010", "01110", "00100", "11111", "11111", "11111", "11111"]
In you case you have 1 string '0b000"00000", "00000", "00000", "00100", "00000", "00000", "00000", "00000"'. And this is not correct stuff causing a problem.
Solution: write you own parcer (or convertor) from your string (comming from flask app form) to a correct python list of strings.
from lcd.
@Jimmy106-e can you show me your code please? Also, I refer you to my GitHub repository, you may find the solution there https://github.com/Jumitti/lcd_home_automation
from lcd.
@Jimmy106-e can you show me your code please? Also, I refer you to my GitHub repository, you may find the solution there https://github.com/Jumitti/lcd_home_automation
Python code (With Flask)
from flask import Flask, render_template, request
import drivers
app = Flask(__name__)
display = drivers.Lcd()
cc = drivers.CustomCharacters(display)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/get_bitmap', methods=['POST'])
def get_bitmap():
bitmap_data = request.form['bitmapData']
print("Bitmap data:", bitmap_data)
cc.char_1_data = [bitmap_data]
#cc.load_custom_characters_data()
print(cc.char_1_data)
#display.lcd_display_extended_string("{0x00}",1)
return '', 204
if __name__ == '__main__':
app.run('0.0.0.0')
HTML (in folder called "templates")
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bitmap Editor</title>
<style>
.grid {
display: grid;
grid-template-columns: repeat(5, 30px);
grid-template-rows: repeat(8, 30px);
gap: 1px;
}
.cell {
width: 30px;
height: 30px;
background-color: white;
border: 1px solid black;
}
.cell.active {
background-color: black;
}
</style>
</head>
<body>
<form action="/get_bitmap" method="post">
<h1>Bitmap Editor</h1>
<div class="grid">
{% for row in range(8) %}
{% for col in range(5) %}
<div class="cell" onclick="toggleCell(this)"></div>
{% endfor %}
{% endfor %}
</div>
<button type="submit">Get Bitmap</button>
<input type="hidden" name="bitmapData" id="bitmapData">
</form>
<script>
function toggleCell(cell) {
cell.classList.toggle('active');
}
document.querySelector('form').addEventListener('submit', function(event) {
event.preventDefault();
const bitmapData = Array.from(document.querySelectorAll('.cell')).map(cell => cell.classList.contains('active') ? 1 : 0).join('');
// Insert comma and quotation marks
let bitmapString = '' ;
for (let i = 0; i < bitmapData.length; i++) {
if (i % 5 === 0) bitmapString += '"';
bitmapString += bitmapData[i];
if ((i + 1) % 5 === 0 && i !== bitmapData.length - 1) bitmapString += '", ';
}
bitmapString += '"'; // Add closing quotation mark
document.getElementById('bitmapData').value = bitmapString;
this.submit();
});
</script>
</body>
</html>
from lcd.
@Jimmy106-e can you show me your code please? Also, I refer you to my GitHub repository, you may find the solution there https://github.com/Jumitti/lcd_home_automation
I checked your repo and you have the custom characters already set while mine are set dynamically, from user input.
from lcd.
@Jimmy106-e Thank you for your answer
I don't understand why you have "0b000" in your error.
ValueError: invalid literal for int() with base 2: '0b000"00000", "00000", "00000", "00100", "00000", "00000", "00000", "00000"'
Are you sure your HTML code is correct? I am not a specialist and even less in HTML but here is what I did to create and generate the binary of a custom character (in HTML). And lightingxd forked my project into Flask too -> fork
We certainly didn't do any dynamics but I think it's in the creation of the custom character binary that there is a problem
from lcd.
I don't understand why you have "0b000" in your error.
see binary_str_cmd
in the method below.
Lines 271 to 284 in b5febdd
the issue is that '0b000"00000", "00000", "00000", "00100", "00000", "00000", "00000", "00000"'
is not a binary literal. it should be '0b0000000000000000000010000000000000000000000'
instead. need to understand why this is happening.
from lcd.
ok thanks
from lcd.
thanks for the feedback, @juvus . closing this issue as a completed.
from lcd.
Related Issues (20)
- smbus is not recognized HOT 20
- No module named smbus HOT 1
- No module named smbus HOT 4
- No module named smbus (sorry if not correct label..)
- Maintaining Python 2.7 compatibility moving forward HOT 1
- Favourite HOT 1
- Removal of the default 'pi' user
- turn off the lcd screen HOT 6
- > ```python
- module not imported running python script at startup raspberry pi /etc/profiles HOT 2
- Cannot run install.sh HOT 5
- would like the cpu/gpu temp display code HOT 3
- Display IP adress HOT 2
- Displaying the IP address shows a b' in front of IP address HOT 2
- demo_tiny_dashboard is broken as Theysaidso api is no longer public
- demo_forex.py is broken because requests is blocked by cloudflare HOT 1
- Omision on README about quotable.io quote length restrictions HOT 2
- LCD Spotify Now Playing + Telegram Bot HOT 7
- BACKLIGHT can't stay in OFF mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lcd.