2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/screen.lua
Qingping Hou 319826c385 mod: screen rotation implemented by ioctl
Now you get a instance rotate :) With only one bug.
I have to restore to previous rotation state of the
native system after exists. Because the native system
does poll the new rotation state that changed by ioctl.

Currently, I don't know how to force the native system
to detect the changes.
2012-03-09 18:34:56 +08:00

76 lines
2.1 KiB
Lua

--[[
Copyright (C) 2011 Hans-Werner Hilse <hilse@web.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]--
--[[
Codes for rotation modes:
1 for no rotation,
2 for landscape with bottom on the right side of screen, etc.
2
+--------------+
| +----------+ |
| | | |
| | Freedom! | |
| | | |
| | | |
3 | | | | 1
| | | |
| | | |
| +----------+ |
| |
| |
+--------------+
0
--]]
Screen = {
cur_rotation_mode = 0,
}
-- @ orien: 1 for clockwise rotate, -1 for anti-clockwise
function Screen:screenRotate(orien)
if orien == "clockwise" then
orien = -1
elseif orien == "anticlockwise" then
orien = 1
else
return
end
self.cur_rotation_mode = (self.cur_rotation_mode + orien) % 4
fb:setOrientation(self.cur_rotation_mode)
fb:close()
--local mode = self.rotation_modes[self.cur_rotation_mode]
--self.cur_rotation_mode = (self.cur_rotation_mode-1 + 1*orien)%4 + 1
--os.execute("lipc-send-event -r 3 com.lab126.hal orientation"..mode)
fb = einkfb.open("/dev/fb0")
end
function Screen:updateRotationMode()
if KEY_FW_DOWN == 116 then -- in EMU mode always set to 0
self.cur_rotation_mode = 0
else
orie_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_orientation", "r"))
updown_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_upside_down", "r"))
self.cur_rotation_mode = orie_fd:read() + (updown_fd:read() * 2)
end
end