فهرست منبع

wallet: add android terminal texture display

darkfi 2 سال پیش
والد
کامیت
061f50c2a0
3فایلهای تغییر یافته به همراه20 افزوده شده و 9 حذف شده
  1. 1 2
      bin/darkwallet/echo.py
  2. 1 1
      bin/darkwallet/gui/api.py
  3. 18 6
      bin/darkwallet/src/util.rs

+ 1 - 2
bin/darkwallet/echo.py

@@ -5,8 +5,7 @@ from pydrk import serial
 context = zmq.Context()
 socket = context.socket(zmq.REQ)
 #self.socket.setsockopt(zmq.IPV6, True)
-#socket.connect(f"tcp://127.0.0.1:9484")
-socket.connect(f"tcp://192.168.1.20:9484")
+socket.connect(f"tcp://127.0.0.1:9484")
 
 req_cmd = bytearray()
 serial.write_u8(req_cmd, 0)

+ 1 - 1
bin/darkwallet/gui/api.py

@@ -2,7 +2,7 @@ from collections import namedtuple
 from pydrk import Api, HostApi, PropertyType, PropertySubType, Property, serial
 import zmq
 
-api = Api(addr="192.168.1.20")
+api = Api()
 host = HostApi(api)
 print("Node status:", api.hello())
 

+ 18 - 6
bin/darkwallet/src/util.rs

@@ -20,12 +20,24 @@ pub fn ansi_texture(width: usize, height: usize, data: &Vec<u8>) -> String {
             let b = (data[idx + 2] as f32) / 255.;
             let a = (data[idx + 3] as f32) / 255.;
 
-            let r = (a * r * 255.) as u8;
-            let g = (a * g * 255.) as u8;
-            let b = (a * b * 255.) as u8;
-
-            let val = "█".truecolor(r, g, b).to_string();
-            out.push_str(&val);
+            #[cfg(target_os = "android")]
+            {
+                if a > 0. {
+                    out.push('█');
+                } else {
+                    out.push(' ');
+                }
+            }
+
+            #[cfg(target_os = "linux")]
+            {
+                let r = (a * r * 255.) as u8;
+                let g = (a * g * 255.) as u8;
+                let b = (a * b * 255.) as u8;
+
+                let val = "█".truecolor(r, g, b).to_string();
+                out.push_str(&val);
+            }
         }
         out.push('│');
         out.push('\n');