<commit_before>local BasePowerD = require("ui/device/basepowerd")

local KoboPowerD = BasePowerD:new{
    fl_min = 1, fl_max = 100,
    flIntensity = 20,
    restore_settings = true,
    fl = nil,
    
    batt_capacity_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity",
    is_charging_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/charge_now",
    battCapacity = nil,
    is_charging = nil,
}

function KoboPowerD:init()
    self.fl = kobolight.open()
end

function KoboPowerD:toggleFrontlight()
    if self.fl ~= nil then
        self.fl:toggle()
    end
end

function KoboPowerD:setIntensityHW()
    if self.fl ~= nil then
        self.fl:setBrightness(self.flIntensity)
    end
end

function KoboPowerD:setIntensitySW()<commit_msg>fail gracefully when the Kobo light device cannot be opened<commit_after>local BasePowerD = require("ui/device/basepowerd")

local KoboPowerD = BasePowerD:new{
    fl_min = 1, fl_max = 100,
    flIntensity = 20,
    restore_settings = true,
    fl = nil,
    
    batt_capacity_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity",
    is_charging_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/charge_now",
    battCapacity = nil,
    is_charging = nil,
}

function KoboPowerD:init()
    local ok, light = pcall(kobolight.open)
    if ok then self.fl = light end
end

function KoboPowerD:toggleFrontlight()
    if self.fl ~= nil then
        self.fl:toggle()
    end
end

function KoboPowerD:setIntensityHW()
    if self.fl ~= nil then
        self.fl:setBrightness(self.flIntensity)
    end
end

function KoboPowerD:setIntensitySW()
{'fraction_non_alphanumeric': 0.1015531660692951, 'fraction_numerical': 0.021505376344086023, 'mean_word_length': 3.7183098591549295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '951855', 'n_tokens_mistral': 630, 'n_tokens_neox': 602, 'n_words': 115}