<commit_before>local Generic = require("device/generic/device")
local TimeVal = require("ui/timeval")
local logger = require("logger")

local function yes() return true end
local function no() return false end

local function getProductId()
    local ntxinfo_pcb = io.popen("/usr/bin/ntxinfo /dev/mmcblk0 | grep pcb | cut -d ':' -f2", "r")
    if not ntxinfo_pcb then return 0 end
    local product_id = tonumber(ntxinfo_pcb:read()) or 0
    ntxinfo_pcb:close()
    return product_id
end

local function isConnected()
    local file = io.open("/sys/class/net/eth0/carrier", "rb")
    if not file then return 0 end
    local carrier = tonumber(file:read("*all")) or 0
    file:close()
    return carrier
end

local Cervantes = Generic:new{
    model = "Cervantes",
    isCervantes = yes,
    isAlwaysPortrait = yes,
    isTouchDevice = yes,
    touch_legacy = true, -- SingleTouch input events
    touch_switch_xy = true,
    touch_mirrored_x = true,
    touch_probe_ev_epoch_time = true,
    hasOTAUpdates = yes,
    hasKeys = yes,

    -- all devices, except the original Cervantes Touch, have frontlight
    hasFrontlight = yes,

    -- currently only Cervantes 4 has coloured frontlight
    hasNaturalLight = no,
}
-- Cervantes Touch
local CervantesTouch = Cervantes:new{
    model = "CervantesTouch",
    display_dpi = 167,
    hasFrontlight = no,
}
-- Cervantes TouchLight / Fnac Touch Plus
local CervantesTouchLight = Cervantes:new{
    model = "CervantesTouchLight",
    display_dpi = 167,
}
-- Cervantes 2013 / Fnac Touch Light
local Cervantes2013 = Cervantes:new{
    model = "Cervantes2013",
    display_dpi = 212,
}
-- Cervantes 3 / Fnac Touch Light 2
local Cervantes3 = Cervantes:new{
    model = "Cervantes3",
    display_dpi = 300,
}
-- Cervantes 4
local Cervantes4 = Cervantes:new{
    model = "Cervantes4",
    display_dpi = 300,
    hasNaturalLight = yes,
    frontlight_settings = {
        frontlight_white = "/sys/class/backlight/lm3630a_ledb",
        frontlight_red = "/sys/class/backlight/lm3630a_leda",
    },
}

-- input events
local probeEvEpochTime
-- this function will update itself after the first touch event
probeEvEpochTime = function(self, ev)
    local now = TimeVal:now()<commit_msg>move Cervantes4 to new natural light interface, like Kobo Forma and Kobo ClaraHD<commit_after>local Generic = require("device/generic/device")
local TimeVal = require("ui/timeval")
local logger = require("logger")

local function yes() return true end
local function no() return false end

local function getProductId()
    local ntxinfo_pcb = io.popen("/usr/bin/ntxinfo /dev/mmcblk0 | grep pcb | cut -d ':' -f2", "r")
    if not ntxinfo_pcb then return 0 end
    local product_id = tonumber(ntxinfo_pcb:read()) or 0
    ntxinfo_pcb:close()
    return product_id
end

local function isConnected()
    local file = io.open("/sys/class/net/eth0/carrier", "rb")
    if not file then return 0 end
    local carrier = tonumber(file:read("*all")) or 0
    file:close()
    return carrier
end

local Cervantes = Generic:new{
    model = "Cervantes",
    isCervantes = yes,
    isAlwaysPortrait = yes,
    isTouchDevice = yes,
    touch_legacy = true, -- SingleTouch input events
    touch_switch_xy = true,
    touch_mirrored_x = true,
    touch_probe_ev_epoch_time = true,
    hasOTAUpdates = yes,
    hasKeys = yes,

    -- all devices, except the original Cervantes Touch, have frontlight
    hasFrontlight = yes,

    -- currently only Cervantes 4 has coloured frontlight
    hasNaturalLight = no,
}
-- Cervantes Touch
local CervantesTouch = Cervantes:new{
    model = "CervantesTouch",
    display_dpi = 167,
    hasFrontlight = no,
}
-- Cervantes TouchLight / Fnac Touch Plus
local CervantesTouchLight = Cervantes:new{
    model = "CervantesTouchLight",
    display_dpi = 167,
}
-- Cervantes 2013 / Fnac Touch Light
local Cervantes2013 = Cervantes:new{
    model = "Cervantes2013",
    display_dpi = 212,
}
-- Cervantes 3 / Fnac Touch Light 2
local Cervantes3 = Cervantes:new{
    model = "Cervantes3",
    display_dpi = 300,
}
-- Cervantes 4
local Cervantes4 = Cervantes:new{
    model = "Cervantes4",
    display_dpi = 300,
    hasNaturalLight = yes,
    frontlight_settings = {
        frontlight_white = "/sys/class/backlight/mxc_msp430_fl.0/brightness",
        frontlight_mixer = "/sys/class/backlight/lm3630a_led/color",
        nl_min = 0,
        nl_max = 10,
        nl_inverted = true,
    },
}

-- input events
local probeEvEpochTime
-- this function will update itself after the first touch event
probeEvEpochTime = function(self, ev)
    local now = TimeVal:now()
{'fraction_non_alphanumeric': 0.09880304678998912, 'fraction_numerical': 0.022633297062023938, 'mean_word_length': 3.4234841193455243, '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': '4608876', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1521, 'n_words': 423}