Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fahrenheit display, alarm control and much more for AK series #9

Open
Tasshack opened this issue Jun 3, 2024 · 1 comment
Open

Comments

@Tasshack
Copy link

Tasshack commented Jun 3, 2024

I have decoded some missing parts of the protocol using a USB monitoring sofware on a Windows machine.

Here are some information that i found;

  • Sending 35 instead of 19 as data[1] will result F symbol to be lit instead of C but you need to convert celcius to fahrenheit on hand before sending it to the device.
  • Sending anything rather than 0 as data[6] will result Temp icon and Temperature value (if shown) to be blinking. This is how alarm feature works from the official app.
  • Sending 180 as data[3] or data[4] will result displaying - (minus) symbol to be shown. This is useful for displaying sub zero temperatures. There are some other characters can be drawn by sending a value larger than 10 but most of them are not meaningful and I could not find correlation between letters can be displayed and number values representing them. Also 10 can be used for displaying a blank segment which is not possible for last segment otherwise.
  • Since top green bar value can be controlled independendent from number value, it can be used for displaying the utilization while number value is displaying the temperature. User can see both utilization and temperature at the same time using this method and every bar led value will be representing 10% of the CPU utilization.

This is the sample code that contains all of the information mentioned above. I hope this helps.

import time
import hid
import psutil
import math

PRODUCT_ID = 0x0001  # AK400
SENSOR = "coretemp"

FAHRENHEIT = True
ALARM_TEMP = 75 # set to 0 to disable
INTERVAL = 0.5

try:
    data = [16, 170] + [0 for i in range(62)]
    h = hid.device()
    h.open(0x3633, PRODUCT_ID)
    h.set_nonblocking(1)
    h.write(data)
    data[1] = 35 if FAHRENHEIT else 19
    while True:
        temperature = psutil.sensors_temperatures()[SENSOR][0].current
        if FAHRENHEIT:
            temperature = (temperature * 1.8) + 32
        temperature = round(max(min(temperature, 999), -99))
        data[2] = math.ceil(psutil.cpu_percent() / 10.0)
        data[6] = ALARM_TEMP > 0 and temperature >= ALARM_TEMP
        value = str(temperature)
        if temperature < -9:
            data[3] = 180
            data[4] = int(value[1])
            data[5] = int(value[2])
        elif temperature < 0:
            data[3] = 0
            data[4] = 180
            data[5] = int(value[1])
        elif temperature < 10:
            data[3] = 0
            data[4] = 0
            data[5] = int(value[0])
        elif temperature < 100:
            data[3] = 0
            data[4] = int(value[0])
            data[5] = int(value[1])
        else:
            data[3] = int(value[0])
            data[4] = int(value[1])
            data[5] = int(value[2])
        h.set_nonblocking(1)
        h.write(data)
        time.sleep(INTERVAL)
except IOError as error:
    print(error)
except KeyboardInterrupt:
    pass
finally:
    if "h" in locals():
        h.close()
@raghulkrishna
Copy link
Owner

Thanks for the info. i will test this out this weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants