Skip to content

Commit

Permalink
Merge pull request #43 from trackmastersteve/master
Browse files Browse the repository at this point in the history
Version 2.2.0
  • Loading branch information
trackmastersteve authored Jul 22, 2018
2 parents 1cbc84b + dce9b86 commit 974dd87
Show file tree
Hide file tree
Showing 21 changed files with 4,541 additions and 31 deletions.
15 changes: 15 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AlienFX is a Linux utility to control the lighting effects of your Alienware com
At present there is a CLI version (``alienfx``) and a gtk GUI version (``alienfx-gtk``). And
has been tested on Debian/Ubuntu/Kali, Fedora and Arch Linux.

[![Version](https://img.shields.io/badge/version-2.1.2-red.svg)]() [![GitHub license](https://img.shields.io/github/license/trackmastersteve/alienfx.svg)](https://github.com/trackmastersteve/alienfx/tree/2.1.x/LICENSE) [![Python3](https://img.shields.io/badge/python-3.6-green.svg)]() [![GitHub issues](https://img.shields.io/github/issues/trackmastersteve/alienfx.svg)](https://github.com/trackmastersteve/alienfx/issues) [![GitHub stars](https://img.shields.io/github/stars/trackmastersteve/alienfx.svg)](https://github.com/trackmastersteve/alienfx/stargazers) [![GitHub forks](https://img.shields.io/github/forks/trackmastersteve/alienfx.svg)](https://github.com/trackmastersteve/alienfx/network)
[![Version](https://img.shields.io/badge/version-2.2.0-red.svg)]() [![GitHub license](https://img.shields.io/github/license/trackmastersteve/alienfx.svg)](https://github.com/trackmastersteve/alienfx/tree/2.1.x/LICENSE) [![Python3](https://img.shields.io/badge/python-3.6-green.svg)]() [![GitHub issues](https://img.shields.io/github/issues/trackmastersteve/alienfx.svg)](https://github.com/trackmastersteve/alienfx/issues) [![GitHub stars](https://img.shields.io/github/stars/trackmastersteve/alienfx.svg)](https://github.com/trackmastersteve/alienfx/stargazers) [![GitHub forks](https://img.shields.io/github/forks/trackmastersteve/alienfx.svg)](https://github.com/trackmastersteve/alienfx/network)

## Table of Contents

Expand All @@ -25,7 +25,7 @@ For 2.0.6:
```sh
$ sudo pacman -S python2-pyusb python2-setuptools python2-gobject python2-cairo
```
For 2.1.x:
For 2.1+:
```sh
$ sudo pacman -S python-pyusb python-setuptools python-gobject python-cairo python-future
```
Expand Down Expand Up @@ -104,10 +104,10 @@ At present, AlienFX supports and has been tested on the following Alienware mode
6. M14xR1 Laptop - support by [Ashwin Menon](https://github.com/ashwinm76)
7. M14xR2   Laptop - (Needs the correct Zone Codes)
8. M14xR3   Laptop - (Needs the correct Zone Codes)
9. M15x Laptop - support by [Gennadiy Chernyshyk](https://github.com/shatur95)
10. M17x Laptop - support by [trackmastersteve](https://github.com/trackmastersteve)
9. M15xR1 Laptop - support by [Gennadiy Chernyshyk](https://github.com/shatur95)
10. M17xR1 Laptop - support by [trackmastersteve](https://github.com/trackmastersteve)
11. M17xR3 Laptop - (Needs the correct Zone Codes)
12. M17xR4 Laptop - (Needs the correct Zone Codes)
12. M17xR4 Laptop - support by [Dennis Marx](https://github.com/derco0n)
13. M18xR2 Laptop - (Needs the correct Zone Codes)
14. Aurora Desktop - support by [Bill Ochetski](https://github.com/ochetski)
15. 17R3 Laptop - (Needs the correct Zone Codes)
Expand Down
23 changes: 21 additions & 2 deletions alienfx/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import alienfx.core.usbdriver as alienfx_usbdriver
import alienfx.core.cmdpacket as alienfx_cmdpacket
import alienfx.core.newcmdpacket as alienfx_newcmdpacket
from alienfx.core.themefile import AlienFXThemeFile
from functools import reduce

Expand Down Expand Up @@ -66,7 +67,9 @@ class AlienFXController(object):
ZONE_STATUS_LEDS = "Status LEDs"
ZONE_POWER_BUTTON = "Power Button"
ZONE_HDD_LEDS = "HDD LEDs"

ZONE_RIGHT_DISPLAY = "Right Display" # LED-bar display right side, as built in the AW17R4
ZONE_LEFT_DISPLAY = "Left Display" # LED-bar display left side, as built in the AW17R4

# State names
STATE_BOOT = "Boot"
STATE_AC_SLEEP = "AC Sleep"
Expand All @@ -75,6 +78,8 @@ class AlienFXController(object):
STATE_BATTERY_SLEEP = "Battery Sleep"
STATE_BATTERY_ON = "Battery On"
STATE_BATTERY_CRITICAL = "Battery Critical"

ALIENFX_CONTROLLER_TYPE = "old" #Modern Notebooks are using 8 bits per color. older ones just 4

def __init__(self):
self.zone_map = {}
Expand All @@ -83,9 +88,23 @@ def __init__(self):
self.state_map = {}
self.vendor_id = 0
self.product_id = 0
# if self.ALIENFX_CONTROLLER_TYPE == "new":
# New controller
# self.cmd_packet = alienfx_newcmdpacket.NewAlienFXCmdPacket()
# else:
# Old Controller
self.cmd_packet = alienfx_cmdpacket.AlienFXCmdPacket()

self._driver = alienfx_usbdriver.AlienFXUSBDriver(self)


def switch_to_new_controller(self):
self.cmd_packet = alienfx_newcmdpacket.NewAlienFXCmdPacket()
return

def switch_to_old_controller(self):
self.cmd_packet = self.cmd_packet = alienfx_cmdpacket.AlienFXCmdPacket()
return

def get_zone_name(self, pkt):
""" Given 3 bytes of a command packet, return a string zone
name corresponding to it
Expand Down
90 changes: 72 additions & 18 deletions alienfx/core/controller_m17xr4.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,78 @@ class AlienFXControllerM17xR4(alienfx_controller.AlienFXController):
# the lowest value that will not result in strange blink/morph behaviour.
DEFAULT_SPEED = 200
MIN_SPEED = 50


# reverse-engineer-knowledgebase:
# ###############################
# NOTICE:
# it seems that alienfx is using doubles for base zone adresses...
# there are a lot more zone- and command-codes which are doing things we dont know about (yet),
# like -for example- setting multiple zones to different colors ans such stuff
# i think that these are used (or can be used) by some games
#
# States: Some zone seem to be only be accessed in some states.
# Caution: different settings for a zone in different states may interfere, so that flashing can happen...
#
# 0x0001 Keyboard right
# 0x0002 Keyboard middle-right
# 0x0004 Keyboard middle-left
# 0x0008 Keyboard left
# 0x000F Keyboard: all fields <= interesting: 0x1 + 0x2 + 0x4 + 0x8 = 0xF
# 0x0010 unknown...
# 0x0020 Alienhead (Display outside)
# 0x0040 Alienware-Logo
# 0x0050 may be: Alienware logo?
# 0x0080 Touchpad
# 0x0100 Power button
# 0x0200 unknown...
#
# side-bars:
# ==========
# 0x0400 seems bottom left
# 0x0800 seems bottom right
# 0x1000 seems top (display) left
# 0x2000 seems top (display) right
#
# 0x4000 seems keyboard macrokey-bar (left)

# Zone codes
LEFT_KEYBOARD = 0x0008
MIDDLE_LEFT_KEYBOARD = 0x0004
MIDDLE_RIGHT_KEYBOARD = 0x0002
RIGHT_KEYBOARD = 0x0001
# Both speakers change together
RIGHT_SPEAKER = 0x0020
LEFT_SPEAKER = 0x0040
ALIEN_HEAD = 0x0080
LOGO = 0x0100
TOUCH_PAD = 0x0200
MEDIA_BAR = 0x0800
POWER_BUTTON = 0x2000
HDD_LEDS = 0x4000
LEFT_KEYBOARD = 0x0008 # Code OK
MIDDLE_LEFT_KEYBOARD = 0x0004 # Code OK
MIDDLE_RIGHT_KEYBOARD = 0x0002 # Code OK
RIGHT_KEYBOARD = 0x0001 # Code OK

RIGHT_SPEAKER = 0x0800 # Code OK, Bottom - Right light bar
LEFT_SPEAKER = 0x0400 # Code OK, Bottom - Left light bar
LEFT_DISPLAY = 0x1000 # Code OK, Display - Left light bar
RIGHT_DISPLAY = 0x2000 # Code OK, Display - Right light bar

ALIEN_HEAD = 0x0020 # Code OK
LOGO = 0x0040 # Code OK. Alienware-logo below screen.
# 0x0060 seems to bee alien head and logo 0x20+0x40=0x60

# Touchpad:
# Seems OK. You may need to set touchpad-lightning to always on in BIOS for this to work,
# as the on-touch-event seems to be not recognized correctly
TOUCH_PAD = 0x0080 # Code OK. Have a look at your BIOS settings.
MEDIA_BAR = 0x4000 # Seems OK. If Media_Bar should be Macro-Key-Bar
POWER_BUTTON = 0x0100 # Seems OK. Caution: S1 (Boot) conflicts with settings for other states...
# HDD_LEDS = 0xf001 # Inactive: Device has no hdd indicator

# Reset codes
RESET_ALL_LIGHTS_OFF = 3
RESET_ALL_LIGHTS_ON = 4

# State codes
BOOT = 1
BOOT = 1 # Seems some zone can only be defined by Boot-State and have no effect on higher states
AC_SLEEP = 2
AC_CHARGED = 5
AC_CHARGING = 6
BATTERY_SLEEP = 7
BATTERY_ON = 8
BATTERY_CRITICAL = 9

#Controller Type
MYCONTROLLER = "new" #Defines the controllertype: old=pre Alienware 17R4 (4 bits per color) / new=AW17R4 and probably others, which are using 8 bits per color

def __init__(self):
alienfx_controller.AlienFXController.__init__(self)
Expand All @@ -77,6 +121,13 @@ def __init__(self):
# USB VID and PID
self.vendor_id = 0x187c
self.product_id = 0x0530

#Switch Controllertype
if self.MYCONTROLLER == "new":
self.switch_to_new_controller()
else:
self.switch_to_old_controller()


# map the zone names to their codes
self.zone_map = {
Expand All @@ -91,13 +142,16 @@ def __init__(self):
self.ZONE_TOUCH_PAD: self.TOUCH_PAD,
self.ZONE_MEDIA_BAR: self.MEDIA_BAR,
self.ZONE_POWER_BUTTON: self.POWER_BUTTON,
self.ZONE_HDD_LEDS: self.HDD_LEDS,
self.ZONE_LEFT_DISPLAY: self.LEFT_DISPLAY,
self.ZONE_RIGHT_DISPLAY: self.RIGHT_DISPLAY
# self.ZONE_HDD_LEDS: self.HDD_LEDS, # Not used, as de AW17R4 does not have an HDD indicator

}

# zones that have special behaviour in the different power states
self.power_zones = [
self.ZONE_POWER_BUTTON,
self.ZONE_HDD_LEDS
self.ZONE_POWER_BUTTON # ,
# self.ZONE_HDD_LEDS
]

# map the reset names to their codes
Expand Down
Loading

0 comments on commit 974dd87

Please sign in to comment.