#!/bin/bash

calc_newval(){
  printf "%02x\n" $( echo "${1}*${2}*0.01" | bc | sed s/\\.[0-9]*// )
}

brightness="$1"

max_r=$(printf "%d\n" 0xff)
max_g=$(printf "%d\n" 0x00)
max_b=$(printf "%d\n" 0xee)

#calc_newval ${max_r} ${brightness}

#exit

calc_r=$( calc_newval ${max_r} ${brightness} )
calc_g=$( calc_newval ${max_g} ${brightness} )
calc_b=$( calc_newval ${max_b} ${brightness} )

g213-led -a "${calc_r}${calc_g}${calc_b}"
